Compare commits
2 Commits
595bd526d4
...
d2b61c6d95
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d2b61c6d95 | ||
![]() |
de06ae4b92 |
@ -0,0 +1,52 @@
|
|||||||
|
package org.jeecg.modules.biz.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.config.shiro.IgnoreAuth;
|
||||||
|
import org.jeecg.modules.biz.dto.CommentWithUserInfo;
|
||||||
|
import org.jeecg.modules.biz.service.ICommentBizService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
@Tag(name = "评论")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/biz/comment")
|
||||||
|
@Slf4j
|
||||||
|
public class CommentBizController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICommentBizService commentBizService;
|
||||||
|
|
||||||
|
@GetMapping("/course/{courseId}/list")
|
||||||
|
@Operation(summary = "查询课程评论列表", description = "根据课程ID查询课程评论列表,包含用户信息")
|
||||||
|
@IgnoreAuth
|
||||||
|
public Result<List<CommentWithUserInfo>> queryCourseCommentList(@PathVariable("courseId") String courseId) {
|
||||||
|
List<CommentWithUserInfo> list = commentBizService.getCommentList("course", courseId);
|
||||||
|
return Result.OK(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @GetMapping("/activity/{activityId}/list")
|
||||||
|
// @Operation(summary = "查询活动评论列表", description = "根据活动ID查询活动评论列表,包含用户信息")
|
||||||
|
// public Result<List<CommentWithUserInfo>> queryActivityCommentList(@PathVariable("activityId") String activityId) {
|
||||||
|
// List<CommentWithUserInfo> list = commentBizService.getCommentList("activity", activityId);
|
||||||
|
// return Result.OK(list);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @GetMapping("/{targetType}/{targetId}/list")
|
||||||
|
// @Operation(summary = "查询通用评论列表", description = "根据目标类型和目标ID查询评论列表,包含用户信息")
|
||||||
|
// public Result<List<CommentWithUserInfo>> queryCommentList(
|
||||||
|
// @PathVariable("targetType") String targetType,
|
||||||
|
// @PathVariable("targetId") String targetId) {
|
||||||
|
// List<CommentWithUserInfo> list = commentBizService.getCommentList(targetType, targetId);
|
||||||
|
// return Result.OK(list);
|
||||||
|
// }
|
||||||
|
}
|
@ -29,7 +29,7 @@ import org.jeecg.modules.gen.resource.entity.Resource;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
@Tag(name = "资源")
|
@Tag(name = "02-资源管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/biz/resource")
|
@RequestMapping("/biz/resource")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -38,7 +38,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Tag(name = "用户")
|
@Tag(name = "03-用户管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/biz/user")
|
@RequestMapping("/biz/user")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package org.jeecg.modules.biz.dto;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "评论信息(包含用户信息)")
|
||||||
|
public class CommentWithUserInfo extends Comment {
|
||||||
|
@Schema(description = "用户姓名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "用户头像")
|
||||||
|
private String userAvatar;
|
||||||
|
|
||||||
|
@Schema(description = "用户标签")
|
||||||
|
private String userTag;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package org.jeecg.modules.biz.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jeecg.modules.biz.dto.CommentWithUserInfo;
|
||||||
|
import org.jeecg.modules.gen.comment.entity.*;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
public interface ICommentBizService extends IService<Comment> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据目标类型和目标ID查询评论列表(包含用户信息)
|
||||||
|
* @param targetType 目标类型
|
||||||
|
* @param targetId 目标ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CommentWithUserInfo> getCommentList(String targetType, String targetId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package org.jeecg.modules.biz.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jeecg.modules.biz.dto.CommentWithUserInfo;
|
||||||
|
import org.jeecg.modules.biz.service.ICommentBizService;
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import org.jeecg.modules.gen.comment.mapper.CommentMapper;
|
||||||
|
import org.jeecg.modules.gen.userinfo.entity.UserInfo;
|
||||||
|
import org.jeecg.modules.gen.userinfo.mapper.UserInfoMapper;
|
||||||
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommentBizServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentBizService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInfoMapper userInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CommentWithUserInfo> getCommentList(String targetType, String targetId) {
|
||||||
|
// 1. 根据目标类型和目标ID查询评论列表
|
||||||
|
QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("target_type", targetType)
|
||||||
|
.eq("target_id", targetId)
|
||||||
|
.orderByDesc("iz_top") // 置顶评论在前
|
||||||
|
.orderByDesc("create_time"); // 按时间倒序
|
||||||
|
|
||||||
|
List<Comment> comments = this.list(queryWrapper);
|
||||||
|
|
||||||
|
// 2. 根据userid关联查询用户信息,构建包含用户信息的评论列表
|
||||||
|
List<CommentWithUserInfo> result = new ArrayList<>();
|
||||||
|
for (Comment comment : comments) {
|
||||||
|
CommentWithUserInfo commentWithUser = new CommentWithUserInfo();
|
||||||
|
// 复制评论基本信息
|
||||||
|
BeanUtils.copyProperties(comment, commentWithUser);
|
||||||
|
|
||||||
|
// 查询用户基本信息
|
||||||
|
SysUser sysUser = sysUserMapper.selectById(comment.getUserId());
|
||||||
|
if (sysUser != null) {
|
||||||
|
commentWithUser.setUserName(sysUser.getRealname());
|
||||||
|
commentWithUser.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
||||||
|
// 查询用户扩展信息
|
||||||
|
UserInfo userInfo = userInfoMapper.selectOne(
|
||||||
|
new QueryWrapper<UserInfo>().eq("user_id", comment.getUserId())
|
||||||
|
);
|
||||||
|
if (userInfo != null) {
|
||||||
|
commentWithUser.setUserTag(userInfo.getTag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(commentWithUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 返回评论列表
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
package org.jeecg.modules.gen.comment.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import org.jeecg.modules.gen.comment.service.ICommentService;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
/**
|
||||||
|
* @Description: 评论
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Tag(name="评论")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/gen/comment/comment")
|
||||||
|
@Slf4j
|
||||||
|
public class CommentController extends JeecgController<Comment, ICommentService> {
|
||||||
|
@Autowired
|
||||||
|
private ICommentService commentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param comment
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "评论-分页列表查询")
|
||||||
|
@Operation(summary="评论-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<Comment>> queryPageList(Comment comment,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
|
||||||
|
|
||||||
|
QueryWrapper<Comment> queryWrapper = QueryGenerator.initQueryWrapper(comment, req.getParameterMap());
|
||||||
|
Page<Comment> page = new Page<Comment>(pageNo, pageSize);
|
||||||
|
IPage<Comment> pageList = commentService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param comment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "评论-添加")
|
||||||
|
@Operation(summary="评论-添加")
|
||||||
|
@RequiresPermissions("gen.comment:comment:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody Comment comment) {
|
||||||
|
commentService.save(comment);
|
||||||
|
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param comment
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "评论-编辑")
|
||||||
|
@Operation(summary="评论-编辑")
|
||||||
|
@RequiresPermissions("gen.comment:comment:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody Comment comment) {
|
||||||
|
commentService.updateById(comment);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "评论-通过id删除")
|
||||||
|
@Operation(summary="评论-通过id删除")
|
||||||
|
@RequiresPermissions("gen.comment:comment:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
commentService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "评论-批量删除")
|
||||||
|
@Operation(summary="评论-批量删除")
|
||||||
|
@RequiresPermissions("gen.comment:comment:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.commentService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "评论-通过id查询")
|
||||||
|
@Operation(summary="评论-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<Comment> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
|
Comment comment = commentService.getById(id);
|
||||||
|
if(comment==null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param comment
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("gen.comment:comment:exportXls")
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, Comment comment) {
|
||||||
|
return super.exportXls(request, comment, Comment.class, "评论");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("gen.comment:comment:importExcel")
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, Comment.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package org.jeecg.modules.gen.comment.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import org.jeecg.common.constant.ProvinceCityArea;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 评论
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("comment")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description="评论")
|
||||||
|
public class Comment implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**用户id*/
|
||||||
|
@Excel(name = "用户id", width = 15)
|
||||||
|
@Schema(description = "用户id")
|
||||||
|
private java.lang.String userId;
|
||||||
|
/**目标类型*/
|
||||||
|
@Excel(name = "目标类型", width = 15)
|
||||||
|
@Schema(description = "目标类型")
|
||||||
|
private java.lang.String targetType;
|
||||||
|
/**目标id*/
|
||||||
|
@Excel(name = "目标id", width = 15)
|
||||||
|
@Schema(description = "目标id")
|
||||||
|
private java.lang.String targetId;
|
||||||
|
/**内容*/
|
||||||
|
@Excel(name = "内容", width = 15)
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private java.lang.String content;
|
||||||
|
/**图片*/
|
||||||
|
@Excel(name = "图片", width = 15)
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private java.lang.String imgs;
|
||||||
|
/**是否置顶*/
|
||||||
|
@Excel(name = "是否置顶", width = 15)
|
||||||
|
@Schema(description = "是否置顶")
|
||||||
|
private java.lang.Integer izTop;
|
||||||
|
/**点赞数*/
|
||||||
|
@Excel(name = "点赞数", width = 15)
|
||||||
|
@Schema(description = "点赞数")
|
||||||
|
private java.lang.Integer likeCount;
|
||||||
|
/**创建人*/
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/**创建日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建日期")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/**更新人*/
|
||||||
|
@Schema(description = "更新人")
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/**更新日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "更新日期")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.jeecg.modules.gen.comment.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 评论
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface CommentMapper extends BaseMapper<Comment> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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="org.jeecg.modules.gen.comment.mapper.CommentMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.jeecg.modules.gen.comment.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 评论
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface ICommentService extends IService<Comment> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.jeecg.modules.gen.comment.service.impl;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.comment.entity.Comment;
|
||||||
|
import org.jeecg.modules.gen.comment.mapper.CommentMapper;
|
||||||
|
import org.jeecg.modules.gen.comment.service.ICommentService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 评论
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
|
||||||
|
|
||||||
|
}
|
@ -41,7 +41,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||||||
/**
|
/**
|
||||||
* @Description: 课程章节
|
* @Description: 课程章节
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-09
|
* @Date: 2025-08-16
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Tag(name="课程章节")
|
@Tag(name="课程章节")
|
||||||
|
@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
|
|||||||
/**
|
/**
|
||||||
* @Description: 课程章节
|
* @Description: 课程章节
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-09
|
* @Date: 2025-08-16
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
/**
|
/**
|
||||||
* @Description: 课程章节
|
* @Description: 课程章节
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-09
|
* @Date: 2025-08-16
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface CourseSectionMapper extends BaseMapper<CourseSection> {
|
public interface CourseSectionMapper extends BaseMapper<CourseSection> {
|
||||||
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
/**
|
/**
|
||||||
* @Description: 课程章节
|
* @Description: 课程章节
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-09
|
* @Date: 2025-08-16
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface ICourseSectionService extends IService<CourseSection> {
|
public interface ICourseSectionService extends IService<CourseSection> {
|
||||||
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
/**
|
/**
|
||||||
* @Description: 课程章节
|
* @Description: 课程章节
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2025-08-09
|
* @Date: 2025-08-16
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@ -0,0 +1,182 @@
|
|||||||
|
package org.jeecg.modules.gen.homework.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.gen.homework.entity.Homework;
|
||||||
|
import org.jeecg.modules.gen.homework.service.IHomeworkService;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
/**
|
||||||
|
* @Description: 作业
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Tag(name="作业")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/gen/homework/homework")
|
||||||
|
@Slf4j
|
||||||
|
public class HomeworkController extends JeecgController<Homework, IHomeworkService> {
|
||||||
|
@Autowired
|
||||||
|
private IHomeworkService homeworkService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param homework
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "作业-分页列表查询")
|
||||||
|
@Operation(summary="作业-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<Homework>> queryPageList(Homework homework,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
|
||||||
|
|
||||||
|
QueryWrapper<Homework> queryWrapper = QueryGenerator.initQueryWrapper(homework, req.getParameterMap());
|
||||||
|
Page<Homework> page = new Page<Homework>(pageNo, pageSize);
|
||||||
|
IPage<Homework> pageList = homeworkService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param homework
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "作业-添加")
|
||||||
|
@Operation(summary="作业-添加")
|
||||||
|
@RequiresPermissions("gen.homework:homework:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody Homework homework) {
|
||||||
|
homeworkService.save(homework);
|
||||||
|
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param homework
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "作业-编辑")
|
||||||
|
@Operation(summary="作业-编辑")
|
||||||
|
@RequiresPermissions("gen.homework:homework:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody Homework homework) {
|
||||||
|
homeworkService.updateById(homework);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "作业-通过id删除")
|
||||||
|
@Operation(summary="作业-通过id删除")
|
||||||
|
@RequiresPermissions("gen.homework:homework:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
homeworkService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "作业-批量删除")
|
||||||
|
@Operation(summary="作业-批量删除")
|
||||||
|
@RequiresPermissions("gen.homework:homework:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.homeworkService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "作业-通过id查询")
|
||||||
|
@Operation(summary="作业-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<Homework> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
|
Homework homework = homeworkService.getById(id);
|
||||||
|
if(homework==null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(homework);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param homework
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("gen.homework:homework:exportXls")
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, Homework homework) {
|
||||||
|
return super.exportXls(request, homework, Homework.class, "作业");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("gen.homework:homework:importExcel")
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, Homework.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package org.jeecg.modules.gen.homework.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import org.jeecg.common.constant.ProvinceCityArea;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 作业
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("homework")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description="作业")
|
||||||
|
public class Homework implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**标题*/
|
||||||
|
@Excel(name = "标题", width = 15)
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private java.lang.String title;
|
||||||
|
/**说明*/
|
||||||
|
@Excel(name = "说明", width = 15)
|
||||||
|
@Schema(description = "说明")
|
||||||
|
private java.lang.String description;
|
||||||
|
/**附件*/
|
||||||
|
@Excel(name = "附件", width = 15)
|
||||||
|
@Schema(description = "附件")
|
||||||
|
private java.lang.String attachment;
|
||||||
|
/**满分*/
|
||||||
|
@Excel(name = "满分", width = 15)
|
||||||
|
@Schema(description = "满分")
|
||||||
|
private java.lang.Integer maxScore;
|
||||||
|
/**及格分数*/
|
||||||
|
@Excel(name = "及格分数", width = 15)
|
||||||
|
@Schema(description = "及格分数")
|
||||||
|
private java.lang.Integer passScore;
|
||||||
|
/**开始时间*/
|
||||||
|
@Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "开始时间")
|
||||||
|
private java.util.Date startTime;
|
||||||
|
/**结束时间*/
|
||||||
|
@Excel(name = "结束时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "结束时间")
|
||||||
|
private java.util.Date endTime;
|
||||||
|
/**状态*/
|
||||||
|
@Excel(name = "状态", width = 15, dicCode = "course_status")
|
||||||
|
@Dict(dicCode = "course_status")
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private java.lang.Integer status;
|
||||||
|
/**创建人*/
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/**创建日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建日期")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/**更新人*/
|
||||||
|
@Schema(description = "更新人")
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/**更新日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "更新日期")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.jeecg.modules.gen.homework.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.jeecg.modules.gen.homework.entity.Homework;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 作业
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface HomeworkMapper extends BaseMapper<Homework> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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="org.jeecg.modules.gen.homework.mapper.HomeworkMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.jeecg.modules.gen.homework.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.homework.entity.Homework;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 作业
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IHomeworkService extends IService<Homework> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.jeecg.modules.gen.homework.service.impl;
|
||||||
|
|
||||||
|
import org.jeecg.modules.gen.homework.entity.Homework;
|
||||||
|
import org.jeecg.modules.gen.homework.mapper.HomeworkMapper;
|
||||||
|
import org.jeecg.modules.gen.homework.service.IHomeworkService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 作业
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-08-16
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class HomeworkServiceImpl extends ServiceImpl<HomeworkMapper, Homework> implements IHomeworkService {
|
||||||
|
|
||||||
|
}
|
@ -44,7 +44,19 @@ export const formSchema: FormSchema[] = [
|
|||||||
{
|
{
|
||||||
label: '课程id',
|
label: '课程id',
|
||||||
field: 'courseId',
|
field: 'courseId',
|
||||||
component: 'Input',
|
component: 'JPopup',
|
||||||
|
componentProps: ({ formActionType }) => {
|
||||||
|
const {setFieldsValue} = formActionType;
|
||||||
|
return{
|
||||||
|
setFieldsValue:setFieldsValue,
|
||||||
|
code:"course_list",
|
||||||
|
fieldConfig: [
|
||||||
|
{ source: 'name', target: 'courseId' },
|
||||||
|
],
|
||||||
|
multi:false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '章节名',
|
label: '章节名',
|
||||||
@ -89,7 +101,7 @@ export const formSchema: FormSchema[] = [
|
|||||||
|
|
||||||
// 高级查询数据
|
// 高级查询数据
|
||||||
export const superQuerySchema = {
|
export const superQuerySchema = {
|
||||||
courseId: {title: '课程id',order: 0,view: 'text', type: 'string',},
|
courseId: {title: '课程id',order: 0,view: 'popup', type: 'string',code: 'course_list', orgFields: 'name', destFields: 'courseId', popupMulti: false,},
|
||||||
name: {title: '章节名',order: 1,view: 'text', type: 'string',},
|
name: {title: '章节名',order: 1,view: 'text', type: 'string',},
|
||||||
type: {title: '章节类型',order: 2,view: 'number', type: 'number',dictCode: 'course_section_type',},
|
type: {title: '章节类型',order: 2,view: 'number', type: 'number',dictCode: 'course_section_type',},
|
||||||
sortOrder: {title: '排序号',order: 3,view: 'number', type: 'number',},
|
sortOrder: {title: '排序号',order: 3,view: 'number', type: 'number',},
|
||||||
|
64
jeecgboot-vue3/src/views/gen/homework/Homework.api.ts
Normal file
64
jeecgboot-vue3/src/views/gen/homework/Homework.api.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import {defHttp} from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from "/@/hooks/web/useMessage";
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/gen/homework/homework/list',
|
||||||
|
save='/gen/homework/homework/add',
|
||||||
|
edit='/gen/homework/homework/edit',
|
||||||
|
deleteOne = '/gen/homework/homework/delete',
|
||||||
|
deleteBatch = '/gen/homework/homework/deleteBatch',
|
||||||
|
importExcel = '/gen/homework/homework/importExcel',
|
||||||
|
exportXls = '/gen/homework/homework/exportXls',
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 导出api
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
/**
|
||||||
|
* 导入api
|
||||||
|
*/
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
/**
|
||||||
|
* 列表接口
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const list = (params) =>
|
||||||
|
defHttp.get({url: Api.list, params});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除单个
|
||||||
|
*/
|
||||||
|
export const deleteOne = (params,handleSuccess) => {
|
||||||
|
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 保存或者更新
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
let url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({url: url, params});
|
||||||
|
}
|
136
jeecgboot-vue3/src/views/gen/homework/Homework.data.ts
Normal file
136
jeecgboot-vue3/src/views/gen/homework/Homework.data.ts
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
import {BasicColumn} from '/@/components/Table';
|
||||||
|
import {FormSchema} from '/@/components/Table';
|
||||||
|
import { rules} from '/@/utils/helper/validator';
|
||||||
|
import { render } from '/@/utils/common/renderUtils';
|
||||||
|
import { getWeekMonthQuarterYear } from '/@/utils';
|
||||||
|
//列表数据
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '标题',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'title'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '说明',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'description',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '附件',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'attachment',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '满分',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'maxScore'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '及格分数',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'passScore'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '开始时间',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'startTime'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '结束时间',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'endTime'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
align:"center",
|
||||||
|
dataIndex: 'status_dictText'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
//查询数据
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
];
|
||||||
|
//表单数据
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '标题',
|
||||||
|
field: 'title',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '说明',
|
||||||
|
field: 'description',
|
||||||
|
component: 'JEditor',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件',
|
||||||
|
field: 'attachment',
|
||||||
|
component: 'JUpload',
|
||||||
|
componentProps:{
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '满分',
|
||||||
|
field: 'maxScore',
|
||||||
|
component: 'InputNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '及格分数',
|
||||||
|
field: 'passScore',
|
||||||
|
component: 'InputNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '开始时间',
|
||||||
|
field: 'startTime',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
showTime: true,
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '结束时间',
|
||||||
|
field: 'endTime',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
showTime: true,
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
field: 'status',
|
||||||
|
component: 'JDictSelectTag',
|
||||||
|
componentProps:{
|
||||||
|
dictCode:"course_status",
|
||||||
|
type: "radio"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// TODO 主键隐藏字段,目前写死为ID
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 高级查询数据
|
||||||
|
export const superQuerySchema = {
|
||||||
|
title: {title: '标题',order: 0,view: 'text', type: 'string',},
|
||||||
|
description: {title: '说明',order: 1,view: 'umeditor', type: 'string',},
|
||||||
|
attachment: {title: '附件',order: 2,view: 'file', type: 'string',},
|
||||||
|
maxScore: {title: '满分',order: 3,view: 'number', type: 'number',},
|
||||||
|
passScore: {title: '及格分数',order: 4,view: 'number', type: 'number',},
|
||||||
|
startTime: {title: '开始时间',order: 5,view: 'datetime', type: 'string',},
|
||||||
|
endTime: {title: '结束时间',order: 6,view: 'datetime', type: 'string',},
|
||||||
|
status: {title: '状态',order: 7,view: 'number', type: 'number',dictCode: 'course_status',},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程表单调用这个方法获取formSchema
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[]{
|
||||||
|
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
||||||
|
return formSchema;
|
||||||
|
}
|
215
jeecgboot-vue3/src/views/gen/homework/HomeworkList.vue
Normal file
215
jeecgboot-vue3/src/views/gen/homework/HomeworkList.vue
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!--引用表格-->
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<!--插槽:table标题-->
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" v-auth="'gen.homework:homework:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||||
|
<a-button type="primary" v-auth="'gen.homework:homework:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||||
|
<j-upload-button type="primary" v-auth="'gen.homework:homework:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined"></Icon>
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button v-auth="'gen.homework:homework:deleteBatch'">批量操作
|
||||||
|
<Icon icon="mdi:chevron-down"></Icon>
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
<!-- 高级查询 -->
|
||||||
|
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||||
|
</template>
|
||||||
|
<!--操作栏-->
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
||||||
|
</template>
|
||||||
|
<!--字段回显插槽-->
|
||||||
|
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||||
|
<template v-if="column.dataIndex==='description'">
|
||||||
|
<!--富文本件字段回显插槽-->
|
||||||
|
<div v-html="text"></div>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex==='attachment'">
|
||||||
|
<!--文件字段回显插槽-->
|
||||||
|
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
|
||||||
|
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<!-- 表单区域 -->
|
||||||
|
<HomeworkModal @register="registerModal" @success="handleSuccess"></HomeworkModal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="gen.homework-homework" setup>
|
||||||
|
import {ref, reactive, computed, unref} from 'vue';
|
||||||
|
import {BasicTable, useTable, TableAction} from '/@/components/Table';
|
||||||
|
import {useModal} from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage'
|
||||||
|
import HomeworkModal from './components/HomeworkModal.vue'
|
||||||
|
import {columns, searchFormSchema, superQuerySchema} from './Homework.data';
|
||||||
|
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './Homework.api';
|
||||||
|
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||||
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { getDateByPicker } from '/@/utils';
|
||||||
|
//日期个性化选择
|
||||||
|
const fieldPickers = reactive({
|
||||||
|
});
|
||||||
|
const queryParam = reactive<any>({});
|
||||||
|
const checkedKeys = ref<Array<string | number>>([]);
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
//注册model
|
||||||
|
const [registerModal, {openModal}] = useModal();
|
||||||
|
//注册table数据
|
||||||
|
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
|
||||||
|
tableProps:{
|
||||||
|
title: '作业',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize:true,
|
||||||
|
formConfig: {
|
||||||
|
//labelWidth: 120,
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter:true,
|
||||||
|
showAdvancedButton:true,
|
||||||
|
fieldMapToNumber: [
|
||||||
|
],
|
||||||
|
fieldMapToTime: [
|
||||||
|
],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 120,
|
||||||
|
fixed:'right'
|
||||||
|
},
|
||||||
|
beforeFetch: (params) => {
|
||||||
|
if (params && fieldPickers) {
|
||||||
|
for (let key in fieldPickers) {
|
||||||
|
if (params[key]) {
|
||||||
|
params[key] = getDateByPicker(params[key], fieldPickers[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Object.assign(params, queryParam);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name:"作业",
|
||||||
|
url: getExportUrl,
|
||||||
|
params: queryParam,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
|
||||||
|
|
||||||
|
// 高级查询配置
|
||||||
|
const superQueryConfig = reactive(superQuerySchema);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高级查询事件
|
||||||
|
*/
|
||||||
|
function handleSuperQuery(params) {
|
||||||
|
Object.keys(params).map((k) => {
|
||||||
|
queryParam[k] = params[k];
|
||||||
|
});
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增事件
|
||||||
|
*/
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, {
|
||||||
|
isUpdate: false,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑事件
|
||||||
|
*/
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除事件
|
||||||
|
*/
|
||||||
|
async function handleDelete(record) {
|
||||||
|
await deleteOne({id: record.id}, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量删除事件
|
||||||
|
*/
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 成功回调
|
||||||
|
*/
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 操作栏
|
||||||
|
*/
|
||||||
|
function getTableAction(record){
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
auth: 'gen.homework:homework:edit'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 下拉操作栏
|
||||||
|
*/
|
||||||
|
function getDropDownAction(record){
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
}, {
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
placement: 'topLeft',
|
||||||
|
},
|
||||||
|
auth: 'gen.homework:homework:delete'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-picker),:deep(.ant-input-number){
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm"></BasicForm>
|
||||||
|
<div style="width: 100%;text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import {BasicForm, useForm} from '/@/components/Form/index';
|
||||||
|
import {computed, defineComponent} from 'vue';
|
||||||
|
import {defHttp} from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import {getBpmFormSchema} from '../Homework.data';
|
||||||
|
import {saveOrUpdate} from '../Homework.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "HomeworkForm",
|
||||||
|
components:{
|
||||||
|
BasicForm
|
||||||
|
},
|
||||||
|
props:{
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props){
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: {span: 24}
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(()=>{
|
||||||
|
if(props.formData.disabled === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let formData = {};
|
||||||
|
const queryByIdUrl = '/gen/homework/homework/queryById';
|
||||||
|
async function initFormData(){
|
||||||
|
let params = {id: props.formData.dataId};
|
||||||
|
const data = await defHttp.get({url: queryByIdUrl, params});
|
||||||
|
formData = {...data}
|
||||||
|
//设置表单的值
|
||||||
|
await setFieldsValue(formData);
|
||||||
|
//默认是禁用
|
||||||
|
await setProps({disabled: formDisabled.value})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
let data = getFieldsValue();
|
||||||
|
let params = Object.assign({}, formData, data);
|
||||||
|
console.log('表单数据', params)
|
||||||
|
await saveOrUpdate(params, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,99 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
||||||
|
<BasicForm @register="registerForm" name="HomeworkForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {ref, computed, unref, reactive} from 'vue';
|
||||||
|
import {BasicModal, useModalInner} from '/@/components/Modal';
|
||||||
|
import {BasicForm, useForm} from '/@/components/Form/index';
|
||||||
|
import {formSchema} from '../Homework.data';
|
||||||
|
import {saveOrUpdate} from '../Homework.api';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { getDateByPicker } from '/@/utils';
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
// Emits声明
|
||||||
|
const emit = defineEmits(['register','success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
const isDetail = ref(false);
|
||||||
|
//表单配置
|
||||||
|
const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: {span: 24}
|
||||||
|
});
|
||||||
|
//表单赋值
|
||||||
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
|
||||||
|
//重置表单
|
||||||
|
await resetFields();
|
||||||
|
setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
isDetail.value = !!data?.showFooter;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
//表单赋值
|
||||||
|
await setFieldsValue({
|
||||||
|
...data.record,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 隐藏底部时禁用整个表单
|
||||||
|
setProps({ disabled: !data?.showFooter })
|
||||||
|
});
|
||||||
|
//日期个性化选择
|
||||||
|
const fieldPickers = reactive({
|
||||||
|
});
|
||||||
|
//设置标题
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
|
||||||
|
//表单提交事件
|
||||||
|
async function handleSubmit(v) {
|
||||||
|
try {
|
||||||
|
let values = await validate();
|
||||||
|
// 预处理日期数据
|
||||||
|
changeDateValue(values);
|
||||||
|
setModalProps({confirmLoading: true});
|
||||||
|
//提交表单
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
//关闭弹窗
|
||||||
|
closeModal();
|
||||||
|
//刷新列表
|
||||||
|
emit('success');
|
||||||
|
} catch ({ errorFields }) {
|
||||||
|
if (errorFields) {
|
||||||
|
const firstField = errorFields[0];
|
||||||
|
if (firstField) {
|
||||||
|
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.reject(errorFields);
|
||||||
|
} finally {
|
||||||
|
setModalProps({confirmLoading: false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理日期值
|
||||||
|
* @param formData 表单数据
|
||||||
|
*/
|
||||||
|
const changeDateValue = (formData) => {
|
||||||
|
if (formData && fieldPickers) {
|
||||||
|
for (let key in fieldPickers) {
|
||||||
|
if (formData[key]) {
|
||||||
|
formData[key] = getDateByPicker(formData[key], fieldPickers[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
/** 时间和数字输入框样式 */
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user