cms功能添加

dev
hechao.zhu 1 year ago
parent 51e0db66db
commit f3e529c6b3
  1. 188
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java
  2. 163
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java
  3. 113
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsArticle.java
  4. 86
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java
  5. 17
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsArticleMapper.java
  6. 17
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java
  7. 5
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml
  8. 14
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsArticleService.java
  9. 14
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java
  10. 18
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsArticleServiceImpl.java
  11. 19
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java
  12. 10
      jeecg-boot-master/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
  13. 64
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts
  14. 143
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.data.ts
  15. 213
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue
  16. 26
      jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle_menu_insert.sql
  17. 70
      jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleForm.vue
  18. 66
      jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleModal.vue
  19. 64
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts
  20. 87
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts
  21. 186
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue
  22. 26
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn_menu_insert.sql
  23. 70
      jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnForm.vue
  24. 66
      jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue

@ -0,0 +1,188 @@
package org.jeecg.modules.demo.cms.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.cms.entity.CmsArticle;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import org.jeecg.modules.demo.cms.service.ICmsArticleService;
import org.jeecg.modules.demo.cms.service.ICmsColumnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
/**
* @Description: 文章
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Api(tags = "文章")
@RestController
@RequestMapping("/cms/cmsArticle")
@Slf4j
public class CmsArticleController extends JeecgController<CmsArticle, ICmsArticleService> {
@Autowired
private ICmsArticleService cmsArticleService;
@Autowired
private ICmsColumnService cmsColumnService;
/**
* 分页列表查询
*
* @param cmsArticle
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "文章-分页列表查询")
@ApiOperation(value = "文章-分页列表查询", notes = "文章-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<CmsArticle>> queryPageList(CmsArticle cmsArticle,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap());
Page<CmsArticle> page = new Page<CmsArticle>(pageNo, pageSize);
IPage<CmsArticle> pageList = cmsArticleService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param cmsArticle
* @return
*/
@AutoLog(value = "文章-添加")
@ApiOperation(value = "文章-添加", notes = "文章-添加")
// @RequiresPermissions("cms:cms_article:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody CmsArticle cmsArticle) {
LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal();
cmsArticle.setCreateBy(principal.getUsername());
CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId());
cmsArticle.setColumnName(cmsColumn.getName());
if (StringUtils.equals("1", cmsArticle.getStatus())) {
cmsArticle.setPublishTime(new Date());
}
cmsArticleService.save(cmsArticle);
return Result.OK("添加成功!");
}
@ApiOperation(value = "文章管理-发布/取消发布", notes = "文章管理-发布/取消发布")
@PostMapping(value = "/operationStatus")
public Result<?> operationStatus(@RequestBody CmsArticle cmsArticle) {
if (StringUtils.equals("1", cmsArticle.getStatus())) {
cmsArticle.setPublishTime(new Date());
}
cmsArticleService.updateById(cmsArticle);
return Result.OK("操作成功!");
}
/**
* 编辑
*
* @param cmsArticle
* @return
*/
@AutoLog(value = "文章-编辑")
@ApiOperation(value = "文章-编辑", notes = "文章-编辑")
// @RequiresPermissions("cms:cms_article:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody CmsArticle cmsArticle) {
cmsArticleService.updateById(cmsArticle);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "文章-通过id删除")
@ApiOperation(value = "文章-通过id删除", notes = "文章-通过id删除")
// @RequiresPermissions("cms:cms_article:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
cmsArticleService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "文章-批量删除")
@ApiOperation(value = "文章-批量删除", notes = "文章-批量删除")
// @RequiresPermissions("cms:cms_article:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.cmsArticleService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "文章-通过id查询")
@ApiOperation(value = "文章-通过id查询", notes = "文章-通过id查询")
@GetMapping(value = "/queryById")
public Result<CmsArticle> queryById(@RequestParam(name = "id", required = true) String id) {
CmsArticle cmsArticle = cmsArticleService.getById(id);
if (cmsArticle == null) {
return Result.error("未找到对应数据");
}
return Result.OK(cmsArticle);
}
/**
* 导出excel
*
* @param request
* @param cmsArticle
*/
// @RequiresPermissions("cms:cms_article:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, CmsArticle cmsArticle) {
return super.exportXls(request, cmsArticle, CmsArticle.class, "文章");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("cms:cms_article:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, CmsArticle.class);
}
}

@ -0,0 +1,163 @@
package org.jeecg.modules.demo.cms.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import org.jeecg.modules.demo.cms.service.ICmsColumnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Api(tags = "cms栏目")
@RestController
@RequestMapping("/cms/cmsColumn")
@Slf4j
public class CmsColumnController extends JeecgController<CmsColumn, ICmsColumnService> {
@Autowired
private ICmsColumnService cmsColumnService;
/**
* 分页列表查询
*
* @param cmsColumn
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "cms栏目-分页列表查询")
@ApiOperation(value = "cms栏目-分页列表查询", notes = "cms栏目-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<CmsColumn>> queryPageList(CmsColumn cmsColumn,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<CmsColumn> queryWrapper = QueryGenerator.initQueryWrapper(cmsColumn, req.getParameterMap());
Page<CmsColumn> page = new Page<CmsColumn>(pageNo, pageSize);
IPage<CmsColumn> pageList = cmsColumnService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param cmsColumn
* @return
*/
@AutoLog(value = "cms栏目-添加")
@ApiOperation(value = "cms栏目-添加", notes = "cms栏目-添加")
// @RequiresPermissions("cms:cms_column:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody CmsColumn cmsColumn) {
cmsColumnService.save(cmsColumn);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param cmsColumn
* @return
*/
@AutoLog(value = "cms栏目-编辑")
@ApiOperation(value = "cms栏目-编辑", notes = "cms栏目-编辑")
// @RequiresPermissions("cms:cms_column:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody CmsColumn cmsColumn) {
cmsColumnService.updateById(cmsColumn);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "cms栏目-通过id删除")
@ApiOperation(value = "cms栏目-通过id删除", notes = "cms栏目-通过id删除")
// @RequiresPermissions("cms:cms_column:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
cmsColumnService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "cms栏目-批量删除")
@ApiOperation(value = "cms栏目-批量删除", notes = "cms栏目-批量删除")
// @RequiresPermissions("cms:cms_column:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.cmsColumnService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "cms栏目-通过id查询")
@ApiOperation(value = "cms栏目-通过id查询", notes = "cms栏目-通过id查询")
@GetMapping(value = "/queryById")
public Result<CmsColumn> queryById(@RequestParam(name = "id", required = true) String id) {
CmsColumn cmsColumn = cmsColumnService.getById(id);
if (cmsColumn == null) {
return Result.error("未找到对应数据");
}
return Result.OK(cmsColumn);
}
/**
* 导出excel
*
* @param request
* @param cmsColumn
*/
// @RequiresPermissions("cms:cms_column:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, CmsColumn cmsColumn) {
return super.exportXls(request, cmsColumn, CmsColumn.class, "cms栏目");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("cms:cms_column:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, CmsColumn.class);
}
}

@ -0,0 +1,113 @@
package org.jeecg.modules.demo.cms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 文章
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Data
@TableName("cms_article")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "cms_article对象", description = "文章")
public class CmsArticle implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
@Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname")
private String createBy;
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**
* 文章标题
*/
@Excel(name = "文章标题", width = 15)
@ApiModelProperty(value = "文章标题")
private String title;
@Excel(name = "状态", width = 15)
@ApiModelProperty(value = "状态")
@Dict(dicCode = "captain_code")
private String status;
/**
* 文章内容
*/
@Excel(name = "文章内容", width = 15)
@ApiModelProperty(value = "文章内容")
private String content;
/**
* 所属栏目
*/
@Excel(name = "所属栏目", width = 15)
@ApiModelProperty(value = "所属栏目")
private String columnId;
/**
* 所属栏目名称
*/
@Excel(name = "所属栏目名称", width = 15)
@ApiModelProperty(value = "所属栏目名称")
private String columnName;
/**
* 来源
*/
@Excel(name = "来源", width = 15)
@ApiModelProperty(value = "来源")
private String source;
/**
* 发布时间
*/
@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")
@ApiModelProperty(value = "发布时间")
private Date publishTime;
/**
* 源url
*/
@Excel(name = "源url", width = 15)
@ApiModelProperty(value = "源url")
private String originUrl;
}

@ -0,0 +1,86 @@
package org.jeecg.modules.demo.cms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Data
@TableName("cms_column")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "cms_column对象", description = "cms栏目")
public class CmsColumn implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建日期
*/
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**
* 排序
*/
@Excel(name = "排序", width = 15)
@ApiModelProperty(value = "排序")
private Integer sort;
/**
* 显示
*/
@Excel(name = "显示", width = 15)
@ApiModelProperty(value = "显示")
private String isShow;
/**
* 名称
*/
@Excel(name = "名称", width = 15)
@ApiModelProperty(value = "名称")
private String name;
/**
* 父级节点
*/
@Excel(name = "父级节点", width = 15)
@ApiModelProperty(value = "父级节点")
private String pid;
/**
* 是否有子节点
*/
@Excel(name = "是否有子节点", width = 15)
@ApiModelProperty(value = "是否有子节点")
private String hasChild;
}

@ -0,0 +1,17 @@
package org.jeecg.modules.demo.cms.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.cms.entity.CmsArticle;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 文章
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
public interface CmsArticleMapper extends BaseMapper<CmsArticle> {
}

@ -0,0 +1,17 @@
package org.jeecg.modules.demo.cms.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
public interface CmsColumnMapper extends BaseMapper<CmsColumn> {
}

@ -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.demo.cms.mapper.CmsColumnMapper">
</mapper>

@ -0,0 +1,14 @@
package org.jeecg.modules.demo.cms.service;
import org.jeecg.modules.demo.cms.entity.CmsArticle;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 文章
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
public interface ICmsArticleService extends IService<CmsArticle> {
}

@ -0,0 +1,14 @@
package org.jeecg.modules.demo.cms.service;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
public interface ICmsColumnService extends IService<CmsColumn> {
}

@ -0,0 +1,18 @@
package org.jeecg.modules.demo.cms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.cms.entity.CmsArticle;
import org.jeecg.modules.demo.cms.mapper.CmsArticleMapper;
import org.jeecg.modules.demo.cms.service.ICmsArticleService;
import org.springframework.stereotype.Service;
/**
* @Description: 文章
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Service
public class CmsArticleServiceImpl extends ServiceImpl<CmsArticleMapper, CmsArticle> implements ICmsArticleService {
}

@ -0,0 +1,19 @@
package org.jeecg.modules.demo.cms.service.impl;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import org.jeecg.modules.demo.cms.mapper.CmsColumnMapper;
import org.jeecg.modules.demo.cms.service.ICmsColumnService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Service
public class CmsColumnServiceImpl extends ServiceImpl<CmsColumnMapper, CmsColumn> implements ICmsColumnService {
}

@ -131,9 +131,9 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource: datasource:
master: master:
url: jdbc:mysql://localhost:3306/comp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://182.92.169.222:3306/comp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: root
password: 123456 password: ycwl2022.
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置 # 多数据源配置
#multi-datasource1: #multi-datasource1:
@ -143,10 +143,10 @@ spring:
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置 #redis 配置
redis: redis:
database: 0 database: 2
host: 127.0.0.1 host: 182.92.169.222
port: 6379 port: 6379
password: '' password: 'redis@ycwl2022.'
#mybatis plus 设置 #mybatis plus 设置
mybatis-plus: mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml

@ -0,0 +1,64 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/cms/cmsArticle/list',
save='/cms/cmsArticle/add',
edit='/cms/cmsArticle/edit',
deleteOne = '/cms/cmsArticle/delete',
deleteBatch = '/cms/cmsArticle/deleteBatch',
importExcel = '/cms/cmsArticle/importExcel',
exportXls = '/cms/cmsArticle/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});
}

@ -0,0 +1,143 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
// import { rules} from '/@/utils/helper/validator';
// import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '所属栏目',
align: "center",
dataIndex: 'columnName'
},
{
title: '文章标题',
align: "center",
dataIndex: 'title',
// slots: {customRender: 'htmlSlot'},
},
{
title: '作者',
align: "center",
dataIndex: 'createBy_dictText'
},
{
title: '来源',
align: "center",
dataIndex: 'source'
},
{
title: '状态',
align: "center",
dataIndex: 'status_dictText'
},
{
title: '发布时间',
align: "center",
dataIndex: 'publishTime'
},
// {
// title: '源url',
// align: "center",
// dataIndex: 'originUrl'
// },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
{
label: "所属栏目",
field: 'columnId',
component: 'JDictSelectTag',
componentProps: {
dictCode: "cms_column,name,id"
},
colProps: {span: 6},
},
{
label: "文章标题",
field: 'title',
component: 'Input',
colProps: {span: 6},
},
{
label: "是否发布",
field: 'status',
component: 'JDictSelectTag',
componentProps: {
dictCode: "captain_code"
},
colProps: {span: 3},
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '文章标题',
field: 'title',
component: 'Input',
dynamicRules: ({model, schema}) => {
return [
{required: true, message: '请输入文章标题!'},
];
},
},
{
label: '所属栏目',
field: 'columnId',
component: 'JDictSelectTag',
componentProps: {
dictCode: "cms_column,name,id"
},
dynamicRules: ({model, schema}) => {
return [
{required: true, message: '请输入所属栏目!'},
];
},
},
{
label: '文章内容',
field: 'content',
component: 'JEditor',
},
// {
// label: '所属栏目名称',
// field: 'columnName',
// component: 'Input',
// },
{
label: '发布时间',
field: 'publishTime',
component: 'DatePicker',
componentProps: {
showTime: true,
valueFormat: 'YYYY-MM-DD HH:mm:ss'
},
},
{
label: '来源',
field: 'source',
component: 'Input',
},
{
label: '源url',
field: 'originUrl',
component: 'Input',
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
];
/**
* formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}

@ -0,0 +1,213 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<!-- <j-upload-button type="primary" 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>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>-->
</template>
<!--操作栏-->
<template #action="{ record }">
<!-- <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>-->
<TableAction :actions="getTableAction(record)" />
<!--<TableAction
:stopButtonPropagation="true"
:actions="[
{
label: '1',
// type: 'link',
size: 'small',
icon: 'ant-design:plus-circle-outlined',
onClick: add.bind(null, record),
},
{
label: '2',
// type: 'link',
size: 'small',
icon: 'fa6-regular:pen-to-square',
onClick: editor.bind(null, record),
},
{
label: '3',
// color: 'error',
icon: 'ic:outline-delete-outline',
popConfirm: {
title: '确定删除该数据吗?',
confirm: del.bind(null, record),
},
},
]"
/>-->
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>
<template #fileSlot="{text}">
<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>
</BasicTable>
<!-- 表单区域 -->
<CmsArticleModal @register="registerModal" @success="handleSuccess"></CmsArticleModal>
</div>
</template>
<script lang="ts" name="cms-cmsArticle" setup>
import {ref, computed, unref} from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import CmsArticleModal from './components/CmsArticleModal.vue'
import {columns, searchFormSchema} from './CmsArticle.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CmsArticle.api';
// import { downloadFile } from '/@/utils/common/renderUtils';
const checkedKeys = ref<Array<string | number>>([]);
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '文章',
api: list,
columns,
canResize:false,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter:true,
showAdvancedButton:true,
fieldMapToNumber: [
],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
},
exportConfig: {
name:"文章",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
/**
* 新增事件
*/
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),
},
{
label: '取消发布',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
/**
* 下拉操作栏
*/
function getDropDownAction(record){
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
</script>
<style scoped>
</style>

@ -0,0 +1,26 @@
-- 注意:该页面对应的前台目录为views/cms文件夹下
-- 如果你想更改到其他目录,请修改sql中component字段对应的值
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
VALUES ('2023101212013790550', NULL, '文章', '/cms/cmsArticleList', 'cms/CmsArticleList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0);
-- 权限控制sql
-- 新增
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790551', '2023101212013790550', '添加文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);
-- 编辑
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790552', '2023101212013790550', '编辑文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);
-- 删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790553', '2023101212013790550', '删除文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);
-- 批量删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790554', '2023101212013790550', '批量删除文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);
-- 导出excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790555', '2023101212013790550', '导出excel_文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);
-- 导入excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2023101212013790556', '2023101212013790550', '导入excel_文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0);

@ -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 '../CmsArticle.data';
import {saveOrUpdate} from '../CmsArticle.api';
export default defineComponent({
name: "CmsArticleForm",
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 = '/cms/cmsArticle/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,66 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref} from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index';
import {formSchema} from '../CmsArticle.data';
import {saveOrUpdate} from '../CmsArticle.api';
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
//
const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = 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;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter })
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} finally {
setModalProps({confirmLoading: false});
}
}
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number){
width: 100%
}
:deep(.ant-calendar-picker){
width: 100%
}
</style>

@ -0,0 +1,64 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/cms/cmsColumn/list',
save='/cms/cmsColumn/add',
edit='/cms/cmsColumn/edit',
deleteOne = '/cms/cmsColumn/delete',
deleteBatch = '/cms/cmsColumn/deleteBatch',
importExcel = '/cms/cmsColumn/importExcel',
exportXls = '/cms/cmsColumn/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});
}

@ -0,0 +1,87 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '栏目名称',
align:"center",
dataIndex: 'name'
},
{
title: '父级节点',
align:"center",
dataIndex: 'pid'
},
{
title: '是否有子节点',
align:"center",
dataIndex: 'hasChild'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
{
label: "栏目名称",
field: 'name',
component: 'Input',
colProps: {span: 6},
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '栏目名称',
field: 'name',
component: 'Input',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入栏目名称!'},
];
},
},
{
label: '父级节点',
field: 'pid',
component: 'Input',
},
{
label: '是否有子节点',
field: 'hasChild',
component: 'Input',
},
{
label: '排序',
field: 'sort',
component: 'InputNumber',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入排序!'},
];
},
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
];
/**
* formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}

@ -0,0 +1,186 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增
</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出
</a-button>
<j-upload-button type="primary" 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>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"
:dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>
<template #fileSlot="{text}">
<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>
</BasicTable>
<!-- 表单区域 -->
<CmsColumnModal @register="registerModal" @success="handleSuccess"></CmsColumnModal>
</div>
</template>
<script lang="ts" name="cms-cmsColumn" setup>
import {ref, computed, unref} from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import {useListPage} from '/@/hooks/system/useListPage'
import CmsColumnModal from './components/CmsColumnModal.vue'
import {columns, searchFormSchema} from './CmsColumn.data';
import {list, deleteOne, batchDelete, getImportUrl, getExportUrl} from './CmsColumn.api';
import {downloadFile} from '/@/utils/common/renderUtils';
const checkedKeys = ref<Array<string | number>>([]);
//model
const [registerModal, {openModal}] = useModal();
//table
const {prefixCls, tableContext, onExportXls, onImportXls} = useListPage({
tableProps: {
title: 'cms栏目',
api: list,
columns,
canResize: false,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
fieldMapToNumber: [],
fieldMapToTime: [],
},
actionColumn: {
width: 120,
fixed: 'right'
},
},
exportConfig: {
name: "cms栏目",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, {reload}, {rowSelection, selectedRowKeys}] = tableContext
/**
* 新增事件
*/
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),
}
]
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
</script>
<style scoped>
</style>

@ -0,0 +1,26 @@
-- -- 注意:该页面对应的前台目录为views/cms文件夹下
-- -- 如果你想更改到其他目录,请修改sql中component字段对应的值
--
--
-- INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
-- VALUES ('2023101208468620390', NULL, 'cms栏目', '/cms/cmsColumnList', 'cms/CmsColumnList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0);
--
-- -- 权限控制sql
-- -- 新增
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620391', '2023101208468620390', '添加cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);
-- -- 编辑
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620392', '2023101208468620390', '编辑cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);
-- -- 删除
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620393', '2023101208468620390', '删除cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);
-- -- 批量删除
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620394', '2023101208468620390', '批量删除cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);
-- -- 导出excel
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620395', '2023101208468620390', '导出excel_cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);
-- -- 导入excel
-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
-- VALUES ('2023101208468620396', '2023101208468620390', '导入excel_cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0);

@ -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 '../CmsColumn.data';
import {saveOrUpdate} from '../CmsColumn.api';
export default defineComponent({
name: "CmsColumnForm",
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 = '/cms/cmsColumn/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,66 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref} from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index';
import {formSchema} from '../CmsColumn.data';
import {saveOrUpdate} from '../CmsColumn.api';
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
//
const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = 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;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter })
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} finally {
setModalProps({confirmLoading: false});
}
}
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number){
width: 100%
}
:deep(.ant-calendar-picker){
width: 100%
}
</style>
Loading…
Cancel
Save