提交 c8981712 authored 作者: zgy's avatar zgy

标签管理优化

上级 c412de24
...@@ -42,7 +42,7 @@ public class TbCfLabelController { ...@@ -42,7 +42,7 @@ public class TbCfLabelController {
List<TbCfLabelEntity> tbCfLabelList = tbCfLabelService.queryList(query); List<TbCfLabelEntity> tbCfLabelList = tbCfLabelService.queryList(query);
int total = tbCfLabelService.queryTotal(query); int total = tbCfLabelService.queryTotal(query);
PageUtils pageUtil = new PageUtils(tbCfLabelList, total, query.getLimit(), query.getPage()); PageUtils pageUtil = new PageUtils(tbCfLabelList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil); return R.ok().put("page", pageUtil);
} }
...@@ -106,4 +106,16 @@ public class TbCfLabelController { ...@@ -106,4 +106,16 @@ public class TbCfLabelController {
return R.ok().put("list", list); return R.ok().put("list", list);
} }
/**
* 查询父标签的子类
*
* @return list
*/
@RequestMapping("/queryParentLabels")
@ResponseBody
public R queryParentLabels(@RequestParam(value = "parentId",defaultValue = "0") String parentId) {
List<TbCfLabelEntity> labelList = tbCfLabelService.queryParentLabels(parentId);
return R.ok().put("list", labelList);
}
} }
...@@ -2,6 +2,8 @@ package com.platform.dao; ...@@ -2,6 +2,8 @@ package com.platform.dao;
import com.platform.entity.TbCfLabelEntity; import com.platform.entity.TbCfLabelEntity;
import java.util.List;
/** /**
* 商品标签Dao * 商品标签Dao
* *
...@@ -10,4 +12,10 @@ import com.platform.entity.TbCfLabelEntity; ...@@ -10,4 +12,10 @@ import com.platform.entity.TbCfLabelEntity;
*/ */
public interface TbCfLabelDao extends BaseDao<TbCfLabelEntity> { public interface TbCfLabelDao extends BaseDao<TbCfLabelEntity> {
/**
* 查询所有父标签
*
* @return list
*/
List<TbCfLabelEntity> queryParentLabels(String parentId);
} }
...@@ -8,7 +8,7 @@ import java.util.Date; ...@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 tb_cf_label * 表名 tb_cf_label
* *
* @author lipengjun * @author lipengjun
* @date 2020-03-12 16:20:26 * @date 2020-03-17 10:38:00
*/ */
public class TbCfLabelEntity implements Serializable { public class TbCfLabelEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -17,6 +17,10 @@ public class TbCfLabelEntity implements Serializable { ...@@ -17,6 +17,10 @@ public class TbCfLabelEntity implements Serializable {
* 标签ID * 标签ID
*/ */
private String id; private String id;
/**
* 父标签ID,如果没有父标签,则为:0
*/
private String parentId;
/** /**
* 标签名 * 标签名
*/ */
...@@ -47,6 +51,19 @@ public class TbCfLabelEntity implements Serializable { ...@@ -47,6 +51,19 @@ public class TbCfLabelEntity implements Serializable {
public String getId() { public String getId() {
return id; return id;
} }
/**
* 设置:父标签ID,如果没有父标签,则为:0
*/
public void setParentId(String parentId) {
this.parentId = parentId;
}
/**
* 获取:父标签ID,如果没有父标签,则为:0
*/
public String getParentId() {
return parentId;
}
/** /**
* 设置:标签名 * 设置:标签名
*/ */
......
...@@ -68,4 +68,11 @@ public interface TbCfLabelService { ...@@ -68,4 +68,11 @@ public interface TbCfLabelService {
* @return 删除条数 * @return 删除条数
*/ */
int deleteBatch(String[] ids); int deleteBatch(String[] ids);
/**
* 查询父标签的子类
*
* @return list
*/
List<TbCfLabelEntity> queryParentLabels(String parentId);
} }
...@@ -60,4 +60,15 @@ public class TbCfLabelServiceImpl implements TbCfLabelService { ...@@ -60,4 +60,15 @@ public class TbCfLabelServiceImpl implements TbCfLabelService {
public int deleteBatch(String[] ids) { public int deleteBatch(String[] ids) {
return tbCfLabelDao.deleteBatch(ids); return tbCfLabelDao.deleteBatch(ids);
} }
/**
* 查询父标签的子类
*
* @return list
*/
@Override
public List<TbCfLabelEntity> queryParentLabels(String parentId) {
return tbCfLabelDao.queryParentLabels(parentId);
}
} }
...@@ -5,15 +5,17 @@ ...@@ -5,15 +5,17 @@
<resultMap type="com.platform.entity.TbCfLabelEntity" id="tbCfLabelMap"> <resultMap type="com.platform.entity.TbCfLabelEntity" id="tbCfLabelMap">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="labelName" column="label_name"/> <result property="labelName" column="label_name"/>
<result property="enableFlag" column="enable_flag"/> <result property="enableFlag" column="enable_flag"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<select id="queryObject" resultType="com.platform.entity.TbCfLabelEntity"> <select id="queryObject" resultType="com.platform.entity.TbCfLabelEntity">
select select
`id`, `id`,
`parent_id`,
`label_name`, `label_name`,
`enable_flag`, `enable_flag`,
`create_time`, `create_time`,
...@@ -22,74 +24,89 @@ ...@@ -22,74 +24,89 @@
where id = #{id} where id = #{id}
</select> </select>
<select id="queryList" resultType="com.platform.entity.TbCfLabelEntity"> <select id="queryList" resultType="com.platform.entity.TbCfLabelEntity">
select
`id`,
`parent_id`,
`label_name`,
`enable_flag`,
`create_time`,
`update_time`
from tb_cf_label
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryParentLabels" resultType="com.platform.entity.TbCfLabelEntity">
select select
`id`, `id`,
`parent_id`,
`label_name`, `label_name`,
`enable_flag`, `enable_flag`,
`create_time`, `create_time`,
`update_time` `update_time`
from tb_cf_label from tb_cf_label
WHERE 1=1 WHERE parent_id=#{parentId}
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select> </select>
<select id="queryTotal" resultType="int"> <select id="queryTotal" resultType="int">
select count(*) from tb_cf_label select count(*) from tb_cf_label
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND name LIKE concat('%',#{name},'%')
</if> </if>
</select> </select>
<insert id="save" parameterType="com.platform.entity.TbCfLabelEntity"> <insert id="save" parameterType="com.platform.entity.TbCfLabelEntity">
insert into tb_cf_label( insert into tb_cf_label(
`id`, `id`,
`parent_id`,
`label_name`, `label_name`,
`enable_flag`, `enable_flag`,
`create_time`, `create_time`,
`update_time`) `update_time`)
values( values(
#{id}, #{id},
#{parentId},
#{labelName}, #{labelName},
#{enableFlag}, #{enableFlag},
#{createTime}, #{createTime},
#{updateTime}) #{updateTime})
</insert> </insert>
<update id="update" parameterType="com.platform.entity.TbCfLabelEntity"> <update id="update" parameterType="com.platform.entity.TbCfLabelEntity">
update tb_cf_label update tb_cf_label
<set> <set>
<if test="labelName != null">`label_name` = #{labelName}, </if> <if test="parentId != null">`parent_id` = #{parentId},</if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}, </if> <if test="labelName != null">`label_name` = #{labelName},</if>
<if test="createTime != null">`create_time` = #{createTime}, </if> <if test="enableFlag != null">`enable_flag` = #{enableFlag},</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if> <if test="createTime != null">`create_time` = #{createTime},</if>
</set> <if test="updateTime != null">`update_time` = #{updateTime}</if>
where id = #{id} </set>
</update> where id = #{id}
</update>
<delete id="delete">
<delete id="delete">
delete from tb_cf_label where id = #{value} delete from tb_cf_label where id = #{value}
</delete> </delete>
<delete id="deleteBatch"> <delete id="deleteBatch">
delete from tb_cf_label where id in delete from tb_cf_label where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div id="rrapp" v-cloak style="height: calc(100% - 15px);"> <div id="rrapp" v-cloak style="height: calc(100% - 15px);">
<div v-show="showList" style="height: 100%;"> <div v-show="showList" style="height: 100%;">
<Row :gutter="16"> <Row :gutter="16">
<div class="search-group"> <div class="search-group">
<i-col span="4"> <i-col span="4">
...@@ -27,26 +27,36 @@ ...@@ -27,26 +27,36 @@
#end #end
</div> </div>
</Row> </Row>
<table id="jqGrid"></table> <table id="jqGrid"></table>
</div> </div>
<Card v-show="!showList"> <Card v-show="!showList">
<p slot="title">{{title}}</p> <p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="tbCfLabel" :rules="ruleValidate" :label-width="80"> <i-form ref="formValidate" :model="tbCfLabel" :rules="ruleValidate" :label-width="80">
<!-- <Form-item label="标签组名" prop="parentId">
<i-input v-model="tbCfLabel.parentId" placeholder="父标签ID,如果没有父标签,则为:0"/>
</Form-item>-->
<Form-item label="标签组名" prop="parentId">
<i-select placeholder="请选择" v-model="tbCfLabel.parentId">
<i-option v-for="(el,i) in labelList" :key='el.id'
:value="el.id">{{el.labelName}}
</i-option>
</i-select>
</Form-item>
<Form-item label="标签名" prop="labelName"> <Form-item label="标签名" prop="labelName">
<i-input v-model="tbCfLabel.labelName" placeholder="标签名"/> <i-input v-model="tbCfLabel.labelName" placeholder="标签名"/>
</Form-item> </Form-item>
<Form-item label="是否启用" prop="enableFlag"> <Form-item label="是否启用" prop="enableFlag">
<i-input v-model="tbCfLabel.enableFlag" placeholder="是否启用 0:不启用 1:启用"/> <i-input v-model="tbCfLabel.enableFlag" placeholder="是否启用 0:不启用 1:启用"/>
</Form-item> </Form-item>
<Form-item> <Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button> <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
<i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button> <i-button type="warning" @click="reload" style="margin-left: 8px"/>
返回</i-button>
<i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button> <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
</Form-item> </Form-item>
</i-form> </i-form>
</Card> </Card>
</div> </div>
<script src="${rc.contextPath}/js/sys/tbcflabel.js?_${date.systemTime}"></script> <script src="${rc.contextPath}/js/sys/tbcflabel.js?_${date.systemTime}"></script>
......
...@@ -3,8 +3,9 @@ $(function () { ...@@ -3,8 +3,9 @@ $(function () {
url: '../tbcflabel/list', url: '../tbcflabel/list',
colModel: [ colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true}, {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
/*{label: '标签组名', name: 'parentId', index: 'parent_id', width: 80},*/
{label: '标签名', name: 'labelName', index: 'label_name', width: 80}, {label: '标签名', name: 'labelName', index: 'label_name', width: 80},
{label: '是否启用', name: 'enableFlag', index: 'enable_flag', width: 80, formatter: validFormat}, {label: '是否启用', name: 'enableFlag', index: 'enable_flag', width: 80,formatter: validFormat},
{label: '创建时间', name: 'createTime', index: 'create_time', width: 80} {label: '创建时间', name: 'createTime', index: 'create_time', width: 80}
] ]
}); });
...@@ -13,6 +14,7 @@ $(function () { ...@@ -13,6 +14,7 @@ $(function () {
let vm = new Vue({ let vm = new Vue({
el: '#rrapp', el: '#rrapp',
data: { data: {
labelList:null,
showList: true, showList: true,
title: null, title: null,
tbCfLabel: {}, tbCfLabel: {},
...@@ -110,5 +112,14 @@ let vm = new Vue({ ...@@ -110,5 +112,14 @@ let vm = new Vue({
handleReset: function (name) { handleReset: function (name) {
handleResetForm(this, name); handleResetForm(this, name);
} }
},
created(){
$.get('../tbcflabel/queryParentLabels', res => {
this.labelList = JSON.parse(res).list;
this.labelList.unshift({
id: "0",
labelName: "标签组",
})
})
} }
}); });
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论