Merge remote-tracking branch 'origin/main' into main

dev
Gitea 1 year ago
commit 982f0e0a2e
  1. 194
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java
  2. 334
      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. 89
      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. 28
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java
  7. 20
      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. 52
      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. 188
      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. 68
      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. 249
      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. 92
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts
  20. 109
      jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts
  21. 315
      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. 112
      jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue

@ -0,0 +1,194 @@
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.util.ObjectUtils;
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());
cmsArticle.setStatus("1");
// }
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) {
CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId());
if (!ObjectUtils.isEmpty(cmsColumn)) {
cmsArticle.setColumnName(cmsColumn.getName());
}
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,334 @@
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.lang.StringUtils;
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.SelectTreeModel;
import org.jeecg.common.util.oConvertUtils;
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;
import java.util.List;
/**
* @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
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@GetMapping(value = "/rootList")
public Result<IPage<CmsColumn>> rootList(CmsColumn CmsColumn,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
// String hasQuery = req.getParameter("hasQuery");
// if (hasQuery != null && "true".equals(hasQuery)) {
// QueryWrapper<CmsColumn> queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap());
// List<CmsColumn> list = cmsColumnService.queryTreeListNoPage(queryWrapper);
// IPage<CmsColumn> pageList = new Page<>(1, 10, list.size());
// pageList.setRecords(list);
// return Result.OK(pageList);
// } else {
// String parentId = CmsColumn.getPid();
// if (oConvertUtils.isEmpty(parentId)) {
// parentId = "0";
// }
// CmsColumn.setPid(null);
// QueryWrapper<CmsColumn> queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap());
// // 使用 eq 防止模糊查询
// queryWrapper.eq("pid", parentId);
// Page<CmsColumn> page = new Page<CmsColumn>(pageNo, pageSize);
// IPage<CmsColumn> pageList = cmsColumnService.page(page, queryWrapper);
// for (CmsColumn CmsColumn1 : pageList.getRecords()) {
// if (CmsColumn1.getPid().equals("0"))
// CmsColumn1.setPid("无上级");
// }
//
// return Result.OK(pageList);
// }
if (oConvertUtils.isEmpty(CmsColumn.getPid())) {
CmsColumn.setPid("0");
}
Result<IPage<CmsColumn>> result = new Result<>();
QueryWrapper<CmsColumn> queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap());
String name = CmsColumn.getName();
if (StringUtils.isBlank(name)) {
queryWrapper.eq("pid", CmsColumn.getPid());
}
Page<CmsColumn> page = new Page<CmsColumn>(pageNo, pageSize);
IPage<CmsColumn> pageList = cmsColumnService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
/**
* vue3专用加载节点的子数据
*
* @param pid
* @return
*/
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = cmsColumnService.queryListByPid(pid);
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* vue3专用加载一级节点/如果是同步 则所有数据
*
* @param async
* @param pcode
* @return
*/
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async,
@RequestParam(name = "pcode") String pcode) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = cmsColumnService.queryListByCode(pcode);
if (!async) {
loadAllChildren(ls);
}
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* vue3专用递归求子节点 同步加载用到
*
* @param ls
*/
private void loadAllChildren(List<SelectTreeModel> ls) {
for (SelectTreeModel tsm : ls) {
List<SelectTreeModel> temp = cmsColumnService.queryListByPid(tsm.getKey());
if (temp != null && temp.size() > 0) {
tsm.setChildren(temp);
loadAllChildren(temp);
}
}
}
/**
* 获取子数据
*
* @param CmsColumn
* @param req
* @return
*/
//@AutoLog(value = "基础能力设置-获取子数据")
@ApiOperation(value = "基础能力设置-获取子数据", notes = "基础能力设置-获取子数据")
@GetMapping(value = "/childList")
public Result<List<CmsColumn>> queryPageList(CmsColumn CmsColumn, HttpServletRequest req) {
Result<List<CmsColumn>> result = new Result();
QueryWrapper<CmsColumn> queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap());
List<CmsColumn> list = cmsColumnService.list(queryWrapper);
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 批量查询子节点
*
* @param parentIds 父ID多个采用半角逗号分割
* @param parentIds
* @return
*/
//@AutoLog(value = "基础能力设置-批量获取子数据")
@ApiOperation(value = "基础能力设置-批量获取子数据", notes = "基础能力设置-批量获取子数据")
@GetMapping("/getChildListBatch")
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
try {
QueryWrapper<CmsColumn> queryWrapper = new QueryWrapper<>();
List<String> parentIdList = Arrays.asList(parentIds.split(","));
queryWrapper.in("pid", parentIdList);
List<CmsColumn> list = cmsColumnService.list(queryWrapper);
IPage<CmsColumn> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("批量查询子节点失败:" + e.getMessage());
}
}
/**
* 添加
*
* @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删除")
@DeleteMapping(value = "/delete")
public Result<CmsColumn> delete(@RequestParam(name = "id", required = true) String id) {
Result<CmsColumn> result = new Result();
CmsColumn sysCategory = cmsColumnService.getById(id);
if (sysCategory == null) {
result.error500("未找到对应实体");
} else {
this.cmsColumnService.delete(id);
result.success("删除成功!");
}
return result;
}
/**
* 批量删除
*
* @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,89 @@
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.jeecg.common.aspect.annotation.Dict;
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 = "显示")
@Dict(dicCode = "captain_code")
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 = "是否有子节点")
@Dict(dicCode = "captain_code")
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,28 @@
package org.jeecg.modules.demo.cms.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.system.vo.SelectTreeModel;
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> {
/**
* @param pid
* @param query
* @return
*/
List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query);
}

@ -0,0 +1,20 @@
<?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">
<select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel">
select
id as "key",
name as "title",
(case when has_child = '1' then 0 else 1 end) as isLeaf,
pid as parentId
from cms_column
where pid = #{pid}
<if test="query != null">
<foreach collection="query.entrySet()" item="value" index="key">
and ${key} = #{value}
</foreach>
</if>
</select>
</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,52 @@
package org.jeecg.modules.demo.cms.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.demo.cms.entity.CmsColumn;
import java.util.List;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
public interface ICmsColumnService extends IService<CmsColumn> {
/**根节点父ID的值*/
public static final String ROOT_PID_VALUE = "0";
/**树节点有子节点状态值*/
public static final String HASCHILD = "1";
/**树节点无子节点状态值*/
public static final String NOCHILD = "0";
/**
* 查询所有数据无分页
*
* @param queryWrapper
* @return List<CmsColumn>
*/
List<CmsColumn> queryTreeListNoPage(QueryWrapper<CmsColumn> queryWrapper);
/**
* vue3专用根据父级编码加载分类字典的数据
*
* @param parentCode
* @return
*/
List<SelectTreeModel> queryListByCode(String parentCode);
/**
* vue3专用根据pid查询子节点集合
*
* @param pid
* @return
*/
List<SelectTreeModel> queryListByPid(String pid);
void delete(String id);
}

@ -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,188 @@
package org.jeecg.modules.demo.cms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.common.util.oConvertUtils;
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 org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @Description: cms栏目
* @Author: jeecg-boot
* @Date: 2023-10-11
* @Version: V1.0
*/
@Service
public class CmsColumnServiceImpl extends ServiceImpl<CmsColumnMapper, CmsColumn> implements ICmsColumnService {
@Override
public List<CmsColumn> queryTreeListNoPage(QueryWrapper<CmsColumn> queryWrapper) {
List<CmsColumn> dataList = baseMapper.selectList(queryWrapper);
List<CmsColumn> mapList = new ArrayList<>();
for (CmsColumn data : dataList) {
String pidVal = data.getPid();
//递归查询子节点的根节点
if (pidVal != null && !ICmsColumnService.NOCHILD.equals(pidVal)) {
CmsColumn rootVal = this.getTreeRoot(pidVal);
if (rootVal != null && !mapList.contains(rootVal)) {
mapList.add(rootVal);
}
} else {
if (!mapList.contains(data)) {
mapList.add(data);
}
}
}
return mapList;
}
@Override
public List<SelectTreeModel> queryListByCode(String parentCode) {
String pid = ROOT_PID_VALUE;
if (oConvertUtils.isNotEmpty(parentCode)) {
LambdaQueryWrapper<CmsColumn> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CmsColumn::getPid, parentCode);
List<CmsColumn> list = baseMapper.selectList(queryWrapper);
if (list == null || list.size() == 0) {
throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
}
if (list.size() > 1) {
throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
}
pid = list.get(0).getId();
}
return baseMapper.queryListByPid(pid, null);
}
@Override
public List<SelectTreeModel> queryListByPid(String pid) {
if (oConvertUtils.isEmpty(pid)) {
pid = ROOT_PID_VALUE;
}
return baseMapper.queryListByPid(pid, null);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String ids) {
String allIds = this.queryTreeChildIds(ids);
String pids = this.queryTreePids(ids);
//1.删除时将节点下所有子节点一并删除
this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(",")));
//2.将父节点中已经没有下级的节点,修改为没有子节点
if (oConvertUtils.isNotEmpty(pids)) {
LambdaUpdateWrapper<CmsColumn> updateWrapper = new UpdateWrapper<CmsColumn>()
.lambda()
.in(CmsColumn::getId, Arrays.asList(pids.split(",")))
.set(CmsColumn::getHasChild, "0");
this.update(updateWrapper);
}
}
/**
* 查询需修改标识的父节点ids
*
* @param ids
* @return
*/
private String queryTreePids(String ids) {
StringBuffer sb = new StringBuffer();
//获取id数组
String[] idArr = ids.split(",");
for (String id : idArr) {
if (id != null) {
CmsColumn category = this.baseMapper.selectById(id);
//根据id查询pid值
String metaPid = category.getPid();
//查询此节点上一级是否还有其他子节点
LambdaQueryWrapper<CmsColumn> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CmsColumn::getPid, metaPid);
queryWrapper.notIn(CmsColumn::getId, Arrays.asList(idArr));
List<CmsColumn> dataList = this.baseMapper.selectList(queryWrapper);
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(metaPid)
&& !sb.toString().contains(metaPid);
if (flag) {
//如果当前节点原本有子节点 现在木有了,更新状态
sb.append(metaPid).append(",");
}
}
}
if (sb.toString().endsWith(SymbolConstant.COMMA)) {
sb = sb.deleteCharAt(sb.length() - 1);
}
return sb.toString();
}
/**
* 递归查询节点的根节点
*
* @param pidVal
* @return
*/
private CmsColumn getTreeRoot(String pidVal) {
CmsColumn data = baseMapper.selectById(pidVal);
if (data != null && !ICmsColumnService.ROOT_PID_VALUE.equals(data.getPid())) {
return this.getTreeRoot(data.getPid());
} else {
return data;
}
}
/**
* 根据id查询所有子节点id
*
* @param ids
* @return
*/
private String queryTreeChildIds(String ids) {
//获取id数组
String[] idArr = ids.split(",");
StringBuffer sb = new StringBuffer();
for (String pidVal : idArr) {
if (pidVal != null) {
if (!sb.toString().contains(pidVal)) {
if (sb.toString().length() > 0) {
sb.append(",");
}
sb.append(pidVal);
this.getTreeChildIds(pidVal, sb);
}
}
}
return sb.toString();
}
/**
* 递归查询所有子节点
*
* @param pidVal
* @param sb
* @return
*/
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
List<CmsColumn> dataList = baseMapper.selectList(new QueryWrapper<CmsColumn>().eq("pid", pidVal));
if (dataList != null && dataList.size() > 0) {
for (CmsColumn tree : dataList) {
if (!sb.toString().contains(tree.getId())) {
sb.append(",").append(tree.getId());
}
this.getTreeChildIds(tree.getId(), sb);
}
}
return sb;
}
}

@ -131,9 +131,9 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
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
password: 123456
password: ycwl2022.
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
@ -143,10 +143,10 @@ spring:
#driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:
database: 0
host: 127.0.0.1
database: 2
host: 182.92.169.222
port: 6379
password: ''
password: 'redis@ycwl2022.'
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml

@ -0,0 +1,68 @@
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',
operationStatus = '/cms/cmsArticle/operationStatus',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
export const updateStatus = (params) => defHttp.post({url: Api.operationStatus, params});
/**
*
* @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,249 @@
<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} from 'vue';
import {BasicTable, 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 {
batchDelete,
deleteOne,
getExportUrl,
getImportUrl,
list,
updateStatus
} from './CmsArticle.api';
// import {updateStatus} from './CmsArticle.api';
import {Update} from "/@/views/topic/Topic.api";
import {defHttp} from "/@/utils/http/axios";
// 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: 180,
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 update2(record: Recordable, val) {
record.status = val;
updateStatus(record)
//2
// defHttp.post({ url: '/cms/cmsArticle/operationStatus', params: record });
reload()
}
/**
* 详情
*/
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) {
const actions = [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
];
if (record.status == "1") {
actions.unshift({
label: '取消发布',
onClick: update2.bind(null,record, "0"),
});
}
if (record.status == "0") {
actions.unshift({
label: '发布',
onClick: update2.bind(null,record, "1"),
});
}
return actions;
}
/**
* 下拉操作栏
*/
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,92 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/cms/cmsColumn/rootList',
save='/cms/cmsColumn/add',
edit='/cms/cmsColumn/edit',
deleteOne = '/cms/cmsColumn/delete',
deleteBatch = '/cms/cmsColumn/deleteBatch',
importExcel = '/cms/cmsColumn/importExcel',
exportXls = '/cms/cmsColumn/exportXls',
loadTreeData = '/cms/cmsColumn/loadTreeRoot',
getChildList = '/cms/cmsColumn/childList',
getChildListBatch = '/cms/cmsColumn/getChildListBatch',
}
/**
* 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});
// }
export const saveOrUpdateDict = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}
/**
*
* @param params
*/
export const loadTreeData = (params) =>
defHttp.get({url: Api.loadTreeData,params});
/**
*
* @param params
*/
export const getChildList = (params) =>
defHttp.get({url: Api.getChildList, params});
/**
*
* @param params
*/
export const getChildListBatch = (params) =>
defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false});

@ -0,0 +1,109 @@
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: 'pid'
// },
{
title: '栏目名称',
align:"left",
dataIndex: 'name',
width: 350,
},
{
title: '显示',
align:"center",
dataIndex: 'isShow_dictText'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
{
label: "栏目名称",
field: 'name',
component: 'Input',
colProps: {span: 6},
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '父级节点',
field: 'pid',
component: 'JTreeSelect',
componentProps: {
dict: 'cms_column,name,id',
pidField: 'pid',
pidValue: '0',
hasChildField: 'has_child',
},
dynamicDisabled: true,
},
{
label: '栏目名称',
field: 'name',
component: 'Input',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入栏目名称!'},
];
},
},
// {
// label: '是否有子节点',
// field: 'hasChild',
// component: 'Input',
// },
{
label: '显示',
field: 'isShow',
component: 'RadioGroup',
componentProps: {
//options里面由一个一个的radio组成,支持disabled
options: [
{ label: '是', value: 1, },
{ label: '否', value: 0 },
],
defaultValue:1,
},
},
{
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,315 @@
<template>
<div>
<!--引用表格-->
<BasicTable
@register="registerTable"
:rowSelection="rowSelection"
:expandedRowKeys="expandedRowKeys"
@expand="handleExpand"
@fetch-success="onFetchSuccess"
>
<!--插槽:table标题-->
<template #tableTitle>
<!-- <a-button type="primary" @click="handleCreate" preIcon="ant-design:plus-outlined"> 新增-->
<!-- </a-button>-->
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出
</a-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="ant-design:down-outlined"></Icon>
</a-button>
</a-dropdown>-->
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</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 CmsColumnModal from './components/CmsColumnModal.vue'
import {columns, searchFormSchema} from './CmsColumn.data';
import {
list,
batchDelete,
getImportUrl,
getExportUrl,
getChildList,
getChildListBatch,
deleteOne
} from './CmsColumn.api';
import {useListPage} from '/@/hooks/system/useListPage'
// import {downloadFile} from '/@/utils/common/renderUtils';
const expandedRowKeys = ref([]);
// 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: 180,
fixed: 'right'
},
isTreeTable: true,
},
exportConfig: {
name: "cms栏目",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
//table
const [registerTable, {reload,collapseAll,updateTableDataRecord, findTableDataRecord,getDataSource}, {rowSelection, selectedRowKeys}] = tableContext
/**
* 新增事件
*/
function handleCreate() {
openModal(true, {
isUpdate: false,
});
}
/**
* 编辑事件
*/
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}, importSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
const ids = selectedRowKeys.value.filter((item) => !item.includes('loading'));
await batchDelete({ ids: ids }, importSuccess);
}
/**
* 导入
*/
function importSuccess() {
//update-begin---author:wangshuai ---date:20220530 for[issues/54]------------
(selectedRowKeys.value = []) && reload();
//update-end---author:wangshuai ---date:20220530 for[issues/54]--------------
}
/**
/**
* 添加下级
*/
function handleAddSub(record) {
openModal(true, {
record,
isUpdate: false,
});
}
/**
* 成功回调
*/
async function handleSuccess({ isUpdate,isSubAdd, values, expandedArr }) {
if (isUpdate) {
//
updateTableDataRecord(values.id, values);
} else {
if (!values['pid']) {
//
reload();
} else {
//
//update-begin-author:liusq---date:20230411--for: [issue/4550]---
if(isSubAdd){
await expandTreeNode(values.pid);
//update-end-author:liusq---date:20230411--for: [issue/4550]---
}else{
expandedRowKeys.value = [];
for (let key of unref(expandedArr)) {
await expandTreeNode(key);
}
}
}
}
}
/**
* 接口请求成功后回调
*/
function onFetchSuccess(result) {
getDataByResult(result.items) && loadDataByExpandedRows();
}
/**
* 根据已展开的行查询数据用于保存后刷新时异步加载子级的数据
*/
async function loadDataByExpandedRows() {
if (unref(expandedRowKeys).length > 0) {
const res = await getChildListBatch({ parentIds: unref(expandedRowKeys).join(',') });
if (res.success && res.result.records.length > 0) {
//
let records = res.result.records;
const listMap = new Map();
for (let item of records) {
let pid = item['pid'];
if (unref(expandedRowKeys).includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
mapList = [];
}
mapList.push(item);
listMap.set(pid, mapList);
}
}
let childrenMap = listMap;
let fn = (list) => {
if (list) {
list.forEach((data) => {
if (unref(expandedRowKeys).includes(data.id)) {
data.children = getDataByResult(childrenMap.get(data.id));
fn(data.children);
}
});
}
};
fn(getDataSource());
}
}
}
/**
* 处理数据集
*/
function getDataByResult(result) {
if (result && result.length > 0) {
return result.map((item) => {
//
if (item['hasChild'] == '1') {
let loadChild = { id: item.id + '_loadChild', name: 'loading...', isLoading: true };
item.children = [loadChild];
}
return item;
});
}
}
/**
*树节点展开合并
* */
async function handleExpand(expanded, record) {
// (expanded)(children)(isLoading)
if (expanded) {
expandedRowKeys.value.push(record.id);
if (record.children.length > 0 && !!record.children[0].isLoading) {
let result = await getChildList({ pid: record.id });
if (result && result.length > 0) {
record.children = getDataByResult(result);
} else {
record.children = null;
record.hasChild = '0';
}
}
} else {
let keyIndex = expandedRowKeys.value.indexOf(record.id);
if (keyIndex >= 0) {
expandedRowKeys.value.splice(keyIndex, 1);
}
}
}
/**
*操作表格后处理树节点展开合并
* */
async function expandTreeNode(key) {
let record:any = findTableDataRecord(key);
if(!expandedRowKeys.value.includes(key)){
expandedRowKeys.value.push(key);
}
let result = await getChildList({ pid: key });
if (result && result.length > 0) {
record.children = getDataByResult(result);
} else {
record.children = null;
record.hasChild = '0';
}
updateTableDataRecord(key, record);
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '确定删除吗?',
confirm: handleDelete.bind(null, record),
},
},
{
label: '添加下级',
onClick: handleAddSub.bind(null, { pid: record.id }),
},
];
}
</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 {saveOrUpdateDict} 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 saveOrUpdateDict(params, true)
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
}
}
});
</script>

@ -0,0 +1,112 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="getTitle" :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 {loadTreeData, saveOrUpdateDict} from '../CmsColumn.api';
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
const expandedRowKeys = ref([]);
const treeData = ref([]);
//
let model:Nullable<Recordable> = null;
//
const [registerForm, {setProps,resetFields, setFieldsValue, validate,updateSchema}] = useForm({
//labelWidth: 150,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: {span: 24},
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
});
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
//
await resetFields();
expandedRowKeys.value = [];
setModalProps({confirmLoading: false, minHeight: 80 ,showOkBtn: !!!data?.hideFooter});
isUpdate.value = !!data?.isUpdate;
if (data?.record) {
model = data.record;
//
await setFieldsValue({
...data.record,
});
} else {
model = null;
}
//
treeData.value = await loadTreeData({'async': false,'pcode':''});
//
setProps({ disabled: !!data?.hideFooter })
});
//
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
/**
* 根据pid获取展开的节点
* @param pid
* @param arr
*/
function getExpandKeysByPid(pid,arr){
if(pid && arr && arr.length>0){
for(let i=0;i<arr.length;i++){
if(arr[i].key==pid && unref(expandedRowKeys).indexOf(pid)<0){
expandedRowKeys.value.push(arr[i].key);
getExpandKeysByPid(arr[i]['parentId'],unref(treeData))
}else{
getExpandKeysByPid(pid,arr[i].children)
}
}
}
}
//
async function handleSubmit() {
try {
let values = await validate();
setModalProps({confirmLoading: true});
//
await saveOrUpdateDict(values, isUpdate.value);
//
closeModal();
//
await getExpandKeysByPid(values['pid'],unref(treeData))
//(isUpdate:;values:;expandedArr:)
emit('success', {
isUpdate: unref(isUpdate),
values: {...values},
expandedArr: unref(expandedRowKeys).reverse(),
//
changeParent: model != null && (model['pid'] != values['pid']),
});
} 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