更新代码
This commit is contained in:
parent
fd952b5462
commit
ceba19f251
@ -1,8 +1,11 @@
|
||||
package com.ruoyi.cms.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.cms.domain.vo.NewCategoryVo;
|
||||
import com.ruoyi.cms.query.CmsContentQuery;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@ -84,10 +87,6 @@ public class CmsCategoryController extends BaseController
|
||||
{
|
||||
return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,栏目名称已存在");
|
||||
}
|
||||
else if (UserConstants.NO_FRAME.equals(cmsCategory.getIsFrame()) && !StringUtils.ishttp(cmsCategory.getCategoryUrl()))
|
||||
{
|
||||
return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
return toAjax(cmsCategoryService.insertCmsCategory(cmsCategory));
|
||||
}
|
||||
|
||||
@ -103,10 +102,6 @@ public class CmsCategoryController extends BaseController
|
||||
{
|
||||
return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,栏目名称已存在");
|
||||
}
|
||||
else if (UserConstants.NO_FRAME.equals(cmsCategory.getIsFrame()) && !StringUtils.ishttp(cmsCategory.getCategoryUrl()))
|
||||
{
|
||||
return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
else if (cmsCategory.getId().equals(cmsCategory.getParentId()))
|
||||
{
|
||||
return error("修改栏目'" + cmsCategory.getCategoryName() + "'失败,上级栏目不能选择自己");
|
||||
@ -136,4 +131,20 @@ public class CmsCategoryController extends BaseController
|
||||
public AjaxResult getContentByCategoryId(CmsContentQuery contentQuery){
|
||||
return success(cmsCategoryService.getContentById(contentQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的叶子节点,除了自己
|
||||
*/
|
||||
@GetMapping("/leavesCategory")
|
||||
public AjaxResult getLeavesCategory(Long id){
|
||||
List<CmsCategory> list = cmsCategoryService.getLeavesCategoryList();
|
||||
List<CmsCategory> result = list.stream().filter(item -> item.getId() != id).collect(Collectors.toList());
|
||||
List<NewCategoryVo> collect = result.stream().map(item -> {
|
||||
NewCategoryVo categoryVo = new NewCategoryVo();
|
||||
BeanUtil.copyProperties(item, categoryVo);
|
||||
categoryVo.setContents(cmsCategoryService.getLeavesContentList(item.getId()));
|
||||
return categoryVo;
|
||||
}).collect(Collectors.toList());
|
||||
return success(collect);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ public class NewTreeSelect{
|
||||
/** 跳转路径 */
|
||||
private String jumpUrl;
|
||||
|
||||
/** 栏目模板 */
|
||||
private String temp;
|
||||
|
||||
/** 子节点 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<NewTreeSelect> children;
|
||||
@ -39,6 +42,7 @@ public class NewTreeSelect{
|
||||
this.id = category.getId();
|
||||
this.label = category.getCategoryName();
|
||||
this.jumpUrl = category.getCategoryUrl();
|
||||
this.temp = category.getTemp();
|
||||
this.children = category.getChildren().stream().map(NewTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ public class CmsCategory extends BaseEntity
|
||||
@Excel(name = "父栏目ID")
|
||||
private Long parentId;
|
||||
|
||||
/** 是否外链(0:否,1:是) */
|
||||
@Excel(name = "是否外链", readConverterExp = "0=:否,1:是")
|
||||
private String isFrame;
|
||||
/** 栏目模板*/
|
||||
@Excel(name = "栏目模板")
|
||||
private String temp;
|
||||
|
||||
/** 是否显示(0:显示,1:不显示,默认0) */
|
||||
@Excel(name = "是否显示(0:显示,1:不显示,默认0)")
|
||||
|
@ -103,6 +103,12 @@ public class CmsContent extends BaseEntity
|
||||
@Excel(name = "视频地址")
|
||||
private List<String> videoUrl;
|
||||
|
||||
/** 链接类型(0=内链,1=外链) */
|
||||
private String linkType;
|
||||
|
||||
/** 链接地址 */
|
||||
private String link;
|
||||
|
||||
/** 逻辑删除0未删除1真删除 */
|
||||
private Integer delFlag;
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.ruoyi.cms.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.ruoyi.cms.domain.CmsContent;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NewCategoryVo {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
/** 栏目ID */
|
||||
private Long id;
|
||||
|
||||
/** 栏目名称 */
|
||||
@Excel(name = "栏目名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 栏目排序(默认0) */
|
||||
@Excel(name = "栏目排序(默认0)")
|
||||
private Long categorySort;
|
||||
|
||||
/** 栏目路径 */
|
||||
@Excel(name = "栏目路径")
|
||||
private String categoryUrl;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
/** 父栏目ID */
|
||||
@Excel(name = "父栏目ID")
|
||||
private Long parentId;
|
||||
|
||||
/** 是否外链(0:否,1:是) */
|
||||
@Excel(name = "是否外链", readConverterExp = "0=:否,1:是")
|
||||
private String isFrame;
|
||||
|
||||
/** 是否显示(0:显示,1:不显示,默认0) */
|
||||
@Excel(name = "是否显示(0:显示,1:不显示,默认0)")
|
||||
private String isDisable;
|
||||
|
||||
/** 逻辑删除0未删除1真删除 */
|
||||
private Integer delFlag;
|
||||
|
||||
private List<CmsContent> contents;
|
||||
}
|
@ -118,4 +118,9 @@ public interface ICmsCategoryService extends IService<CmsCategory>
|
||||
* @return
|
||||
*/
|
||||
List<CmsCategory> getLeavesCategoryList();
|
||||
|
||||
/**
|
||||
* 按ID查询所有文章
|
||||
*/
|
||||
List<CmsContent> getLeavesContentList(Long id);
|
||||
}
|
||||
|
@ -256,4 +256,15 @@ public class CmsCategoryServiceImpl extends ServiceImpl<CmsCategoryMapper, CmsCa
|
||||
public List<CmsCategory> getLeavesCategoryList() {
|
||||
return baseMapper.selectList(new QueryWrapper<CmsCategory>().ne("parent_id", 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按ID查询所有文章
|
||||
*/
|
||||
@Override
|
||||
public List<CmsContent> getLeavesContentList(Long id){
|
||||
return contentMapper.selectList(new QueryWrapper<CmsContent>().and(item -> {
|
||||
item.eq("category_id", id)
|
||||
.eq("del_flag", 0);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,10 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
# master:
|
||||
# url: jdbc:mysql://122.51.230.86:3306/hgd_website?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: hgdRoot
|
||||
# password: qqzcy@1014
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/ry-cms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
|
@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="categorySort" column="category_sort" />
|
||||
<result property="categoryUrl" column="category_url" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="isFrame" column="is_frame" />
|
||||
<result property="temp" column="temp" />
|
||||
<result property="isDisable" column="is_disable" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsCategoryVo">
|
||||
select id, category_name, category_sort, category_url, parent_id, is_frame, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category
|
||||
select id, category_name, category_sort, category_url, parent_id, temp, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsCategoryList" parameterType="CmsCategory" resultMap="CmsCategoryResult">
|
||||
@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null "> and category_sort = #{categorySort}</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''"> and category_url = #{categoryUrl}</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="isFrame != null "> and is_frame = #{isFrame}</if>
|
||||
<if test="temp != null "> and temp = #{temp}</if>
|
||||
<if test="isDisable != null "> and is_disable = #{isDisable}</if>
|
||||
and del_flag = 0
|
||||
</where>
|
||||
@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">category_sort,</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">category_url,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="isFrame != null">is_frame,</if>
|
||||
<if test="temp != null">temp,</if>
|
||||
<if test="isDisable != null">is_disable,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">#{categorySort},</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">#{categoryUrl},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="isFrame != null">#{isFrame},</if>
|
||||
<if test="temp != null">#{temp},</if>
|
||||
<if test="isDisable != null">#{isDisable},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">category_sort = #{categorySort},</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">category_url = #{categoryUrl},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="isFrame != null">is_frame = #{isFrame},</if>
|
||||
<if test="temp != null">temp = #{temp},</if>
|
||||
<if test="isDisable != null">is_disable = #{isDisable},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
|
@ -33,6 +33,8 @@
|
||||
typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="videoUrl" column="video_url" javaType="java.util.List"
|
||||
typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="linkType" column="link_type" />
|
||||
<result property="link" column="link" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsContentVo">
|
||||
@ -60,7 +62,9 @@
|
||||
create_time,
|
||||
create_by,
|
||||
update_time,
|
||||
update_by
|
||||
update_by,
|
||||
link_type,
|
||||
link
|
||||
from cms_content
|
||||
</sql>
|
||||
|
||||
@ -121,6 +125,8 @@
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="linkType != null">link_type,</if>
|
||||
<if test="link != null">link,</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url,</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url,</if>
|
||||
</trim>
|
||||
@ -150,6 +156,8 @@
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="linkType != null">#{linkType},</if>
|
||||
<if test="link != null">#{link},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">
|
||||
#{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
</if>
|
||||
@ -184,6 +192,8 @@
|
||||
create_by = #{createBy},
|
||||
update_time = #{updateTime},
|
||||
update_by = #{updateBy},
|
||||
link_type = #{linkType},
|
||||
link = #{link},
|
||||
image_url = #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
video_url = #{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
</trim>
|
||||
|
@ -5,6 +5,10 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
# master:
|
||||
# url: jdbc:mysql://122.51.230.86:3306/hgd_website?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: hgdRoot
|
||||
# password: qqzcy@1014
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/ry-cms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
|
@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="categorySort" column="category_sort" />
|
||||
<result property="categoryUrl" column="category_url" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="isFrame" column="is_frame" />
|
||||
<result property="temp" column="temp" />
|
||||
<result property="isDisable" column="is_disable" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsCategoryVo">
|
||||
select id, category_name, category_sort, category_url, parent_id, is_frame, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category
|
||||
select id, category_name, category_sort, category_url, parent_id, temp, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsCategoryList" parameterType="CmsCategory" resultMap="CmsCategoryResult">
|
||||
@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null "> and category_sort = #{categorySort}</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''"> and category_url = #{categoryUrl}</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="isFrame != null "> and is_frame = #{isFrame}</if>
|
||||
<if test="temp != null "> and temp = #{temp}</if>
|
||||
<if test="isDisable != null "> and is_disable = #{isDisable}</if>
|
||||
and del_flag = 0
|
||||
</where>
|
||||
@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">category_sort,</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">category_url,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="isFrame != null">is_frame,</if>
|
||||
<if test="temp != null">temp,</if>
|
||||
<if test="isDisable != null">is_disable,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">#{categorySort},</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">#{categoryUrl},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="isFrame != null">#{isFrame},</if>
|
||||
<if test="temp != null">#{temp},</if>
|
||||
<if test="isDisable != null">#{isDisable},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="categorySort != null">category_sort = #{categorySort},</if>
|
||||
<if test="categoryUrl != null and categoryUrl != ''">category_url = #{categoryUrl},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="isFrame != null">is_frame = #{isFrame},</if>
|
||||
<if test="temp != null">temp = #{temp},</if>
|
||||
<if test="isDisable != null">is_disable = #{isDisable},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
|
@ -33,6 +33,8 @@
|
||||
typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="videoUrl" column="video_url" javaType="java.util.List"
|
||||
typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/>
|
||||
<result property="linkType" column="link_type" />
|
||||
<result property="link" column="link" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsContentVo">
|
||||
@ -60,7 +62,9 @@
|
||||
create_time,
|
||||
create_by,
|
||||
update_time,
|
||||
update_by
|
||||
update_by,
|
||||
link_type,
|
||||
link
|
||||
from cms_content
|
||||
</sql>
|
||||
|
||||
@ -121,6 +125,8 @@
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="linkType != null">link_type,</if>
|
||||
<if test="link != null">link,</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">image_url,</if>
|
||||
<if test="videoUrl != null and videoUrl.size() != 0">video_url,</if>
|
||||
</trim>
|
||||
@ -150,6 +156,8 @@
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="linkType != null">#{linkType},</if>
|
||||
<if test="link != null">#{link},</if>
|
||||
<if test="imageUrl != null and imageUrl.size() != 0">
|
||||
#{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
</if>
|
||||
@ -184,6 +192,8 @@
|
||||
create_by = #{createBy},
|
||||
update_time = #{updateTime},
|
||||
update_by = #{updateBy},
|
||||
link_type = #{linkType},
|
||||
link = #{link},
|
||||
image_url = #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
video_url = #{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler},
|
||||
</trim>
|
||||
|
@ -42,3 +42,11 @@ export function delCategory(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 取所有的叶子节点
|
||||
export function getLeavesCategory(id){
|
||||
return request({
|
||||
url: "/cms/category/leavesCategory",
|
||||
params: id
|
||||
})
|
||||
}
|
||||
|
@ -132,17 +132,15 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="isFrame">
|
||||
<span slot="label">
|
||||
<el-tooltip content="选择是外链则栏目路径需要以`http(s)://`开头" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
是否外链
|
||||
</span>
|
||||
<el-radio-group v-model="form.isFrame">
|
||||
<el-radio label="0">否</el-radio>
|
||||
<el-radio label="1">是</el-radio>
|
||||
</el-radio-group>
|
||||
<el-form-item label="栏目模板" prop="temp">
|
||||
<el-select v-model="form.temp" placeholder="请选择栏目模板" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.category_temp"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -192,7 +190,7 @@ import {getMenu} from "@/api/system/menu";
|
||||
|
||||
export default {
|
||||
name: "Category",
|
||||
dicts: ['cms_category_disable'],
|
||||
dicts: ['cms_category_disable', "category_temp"],
|
||||
components: { Treeselect, IconSelect },
|
||||
data() {
|
||||
return {
|
||||
@ -233,7 +231,7 @@ export default {
|
||||
{ required: true, message: "栏目名称不能为空", trigger: "blur" }
|
||||
],
|
||||
categorySort: [
|
||||
{ required: true, message: "栏目排序(默认0)不能为空", trigger: "blur" }
|
||||
{ required: true, message: "栏目排序不能为空", trigger: "blur" }
|
||||
],
|
||||
categoryUrl: [
|
||||
{ required: true, message: "栏目路径不能为空", trigger: "blur" }
|
||||
@ -242,7 +240,7 @@ export default {
|
||||
{ required: true, message: "父栏目不能为空", trigger: "change" }
|
||||
],
|
||||
isDisable: [
|
||||
{ required: true, message: "是否显示(0:显示,1:不显示,默认0)不能为空", trigger: "blur" }
|
||||
{ required: true, message: "是否显示不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
};
|
||||
@ -288,7 +286,7 @@ export default {
|
||||
createBy: null,
|
||||
updateTime: null,
|
||||
updateBy: null,
|
||||
isFrame: "0",
|
||||
temp: "0",
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
|
@ -175,6 +175,11 @@ export default {
|
||||
type: String,
|
||||
defaultValue: undefined,
|
||||
required: false
|
||||
},
|
||||
temp: {
|
||||
type: String,
|
||||
defaultValue: undefined,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -193,6 +198,7 @@ export default {
|
||||
delFlag: "0",
|
||||
},
|
||||
total: 0,
|
||||
tempType: "0",
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -201,10 +207,13 @@ export default {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
categoryId: newVal,
|
||||
delFlag: "0"
|
||||
delFlag: "0",
|
||||
}
|
||||
this.getList()
|
||||
}
|
||||
},
|
||||
temp(newVal){
|
||||
this.tempType = newVal
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.cid === "") {
|
||||
@ -217,7 +226,7 @@ export default {
|
||||
methods: {
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.$router.push({path: '/content/editor', query: {"categoryId": this.queryParams.categoryId}})
|
||||
this.$router.push({path: '/content/editor', query: {"categoryId": this.queryParams.categoryId, "temp": this.tempType}})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
<el-tabs v-model="activeName" @tab-click="handleTabClick">
|
||||
<!-- 内容列表-->
|
||||
<el-tab-pane label="内容列表" name="contentList">
|
||||
<cms-content-list v-if="activeName==='contentList'" :cid="selectCategoryId"></cms-content-list>
|
||||
<cms-content-list v-if="activeName==='contentList'" :cid="selectCategoryId" :temp="temp"></cms-content-list>
|
||||
</el-tab-pane>
|
||||
<!-- 回收站-->
|
||||
<el-tab-pane label="回收站" name="recycle">
|
||||
@ -93,6 +93,7 @@ export default {
|
||||
{key: 3, label: `内容状态`, visible: true},
|
||||
{key: 4, label: `创建时间`, visible: true},
|
||||
],
|
||||
temp: "0"
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -161,6 +162,7 @@ export default {
|
||||
// 节点单击事件
|
||||
handleNodeClick(data) {
|
||||
this.selectCategoryId = data.id;
|
||||
this.temp = data.temp;
|
||||
},
|
||||
/** 查询栏目下拉树结构 */
|
||||
getCategoryTree() {
|
||||
|
@ -24,7 +24,7 @@
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="内容描述" prop="summary">
|
||||
<el-form-item label="简介" prop="summary">
|
||||
<el-input
|
||||
v-model="form.summary"
|
||||
maxlength="360"
|
||||
@ -32,6 +32,37 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="链接类型" prop="linkType">
|
||||
<el-radio-group v-model="form.linkType" @change="handleChangeLinkType">
|
||||
<el-radio-button
|
||||
v-for="dict in dict.type.cms_link_type"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="linkType === '0'" class="art-title bg-purple-white">
|
||||
<el-form-item label="链接地址" prop="link">
|
||||
<el-cascader
|
||||
v-model="chooseValue"
|
||||
:options="linkList"
|
||||
@change="handleChange"></el-cascader>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="linkType === '1'" class="art-title bg-purple-white">
|
||||
<el-form-item label="链接地址" prop="link">
|
||||
<el-input
|
||||
v-model="form.link"
|
||||
maxlength="360"
|
||||
placeholder="http(s)://"
|
||||
show-word-limit>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="art-title bg-purple-white">
|
||||
<el-form-item label="内容类型" prop="contentType">
|
||||
<el-radio-group v-model="form.contentType" @change="handleChangeType">
|
||||
@ -83,7 +114,7 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="缩略图" prop="logo">
|
||||
<el-form-item label="缩略图" prop="contentImg">
|
||||
<image-upload :limit="1" v-model="form.contentImg"></image-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
@ -92,13 +123,13 @@
|
||||
<el-form-item label="编辑" prop="editor">
|
||||
<el-input v-model="form.editor"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="原创" prop="original">
|
||||
<el-switch
|
||||
v-model="form.original"
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="原创" prop="original">-->
|
||||
<!-- <el-switch-->
|
||||
<!-- v-model="form.original"-->
|
||||
<!-- active-value="0"-->
|
||||
<!-- inactive-value="1"-->
|
||||
<!-- ></el-switch>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="来源" prop="source">
|
||||
<el-input v-model="form.source"/>
|
||||
</el-form-item>
|
||||
@ -121,11 +152,12 @@
|
||||
<script>
|
||||
import VueUeditorWrap from "vue-ueditor-wrap";
|
||||
import {getLeavesCategoryList} from "@/api/cms/editor"
|
||||
import { getLeavesCategory, getLeavesContent } from '@/api/cms/category'
|
||||
import {addContent, getContent, updateContent} from "@/api/cms/content";
|
||||
|
||||
export default {
|
||||
name: "Content",
|
||||
dicts: ['cms_content_type'],
|
||||
dicts: ['cms_content_type', 'cms_link_type'],
|
||||
components: {
|
||||
VueUeditorWrap
|
||||
},
|
||||
@ -155,6 +187,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chooseValue: [],
|
||||
openResourceDialog: false,
|
||||
isType: "0",
|
||||
activeName: "basic",
|
||||
@ -175,7 +208,9 @@ export default {
|
||||
summary: '',
|
||||
status: '0',
|
||||
isAccessory: '0',
|
||||
accessoryUrl: []
|
||||
accessoryUrl: [],
|
||||
linkType: "0",
|
||||
link: ''
|
||||
},
|
||||
rules: {
|
||||
contentTitle: [{required: true, message: "内容标题不能为空", trigger: "blur"}],
|
||||
@ -191,6 +226,8 @@ export default {
|
||||
UEDITOR_CORS_URL: '/static/UEditorPlus/',
|
||||
},
|
||||
categoryList: "",
|
||||
linkType: "0",
|
||||
linkList: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -213,14 +250,11 @@ export default {
|
||||
status: '0',
|
||||
isAccessory: '0',
|
||||
accessoryUrl: [],
|
||||
id: ""
|
||||
id: "",
|
||||
linkType: "0",
|
||||
link: ''
|
||||
}
|
||||
},
|
||||
handleCatalogChange() {
|
||||
this.openCatalogSelector = true;
|
||||
this.disableLinkCatalog = false;
|
||||
this.catalogSelectorFor = "change";
|
||||
},
|
||||
getCategoryList() {
|
||||
getLeavesCategoryList().then(response => {
|
||||
this.categoryList = response.data
|
||||
@ -241,6 +275,9 @@ export default {
|
||||
handleChangeType() {
|
||||
this.isType = this.form.contentType
|
||||
},
|
||||
handleChangeLinkType() {
|
||||
this.linkType = this.form.linkType
|
||||
},
|
||||
handleEdit() {
|
||||
this.openResourceDialog = true;
|
||||
},
|
||||
@ -266,7 +303,6 @@ export default {
|
||||
updateContent(this.form).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess(this.form.status !== "1" ? "保存成功" : "发布成功");
|
||||
this.reset()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@ -274,7 +310,6 @@ export default {
|
||||
addContent(this.form).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess(this.form.status !== "1" ? "保存成功" : "发布成功");
|
||||
this.reset()
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -286,7 +321,9 @@ export default {
|
||||
getContentById(contentId) {
|
||||
getContent(contentId).then(res => {
|
||||
this.form = res.data
|
||||
this.listLeavesCategory(this.form.categoryId)
|
||||
this.isType = this.form.contentType
|
||||
this.linkType = this.form.linkType
|
||||
})
|
||||
},
|
||||
StrToArr(value) {
|
||||
@ -311,6 +348,32 @@ export default {
|
||||
this.form.videoUrl = []
|
||||
}
|
||||
},
|
||||
listLeavesCategory(id){
|
||||
getLeavesCategory(id).then(res => {
|
||||
res.data.forEach(item => {
|
||||
const x = {
|
||||
label: item.categoryName,
|
||||
value: item.categoryUrl,
|
||||
children: this.createLink(item.contents)
|
||||
}
|
||||
this.linkList.push(x)
|
||||
})
|
||||
})
|
||||
},
|
||||
createLink(contents){
|
||||
let list = []
|
||||
contents.forEach(item => {
|
||||
const x = {
|
||||
label: item.contentTitle,
|
||||
value: item.id
|
||||
}
|
||||
list.push(x)
|
||||
})
|
||||
return list
|
||||
},
|
||||
handleChange(value) {
|
||||
this.form.link = value[1]
|
||||
},
|
||||
formatTimer: function(value) {
|
||||
let date = new Date(value);
|
||||
let y = date.getFullYear();
|
||||
|
@ -5,7 +5,7 @@
|
||||
<span>快捷方式</span>
|
||||
</div>
|
||||
<div class="body">
|
||||
<el-card v-for="shortcut in shortcuts" :key="shortcut.router" shadow="hover" :body-style="{ padding: '0 10px' }" style="float: left;margin-right:10px;margin-bottom:10px;">
|
||||
<el-card v-for="shortcut in shortcuts" :key="shortcut.router" shadow="hover" :body-style="{ padding: '0 15px 0 0' }" style="float: left;margin-right:10px;margin-bottom:10px;">
|
||||
<el-link class="shortcut-link" @click="handleShortcutRedirect(shortcut.path)">
|
||||
<svg-icon :icon-class="shortcut.icon" class-name="card-panel-icon"></svg-icon>
|
||||
<div class="shortcut-text">
|
||||
|
Loading…
Reference in New Issue
Block a user