百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

JAVA全栈CMS系统应用summer富文本编辑器,输入框自动索引功能9

bigegpt 2024-11-16 17:11 6 浏览

1.富文本编辑器summernote,一款基于bootstrap框架的编辑器,自适应屏幕大小,便于多平台开发

官网:https://summernote.org/


  • 页面引入cdn连接js、css
<!-- include libraries(jQuery, bootstrap) -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

<!-- include summernote css/js -->
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>


2.后端更新大字段mediumText调用的mybatis方法,默认的update不支持大字段更新





3.前端页面addModule更新,mounted初始化富文本,save保存时,获取content内容

<el-form-item label="模块内容" prop="moduleContent">
    <!--<el-input id="moduleContent" class="inputLine" v-model="module.moduleContent"></el-input>-->
    <el-input id="content" v-model="module.moduleContent"></el-input>
</el-form-item>

…….
mounted() {
    console.log(this.message);
    console.log("传入的params:", this.$route.params.module);
    if (this.$route.params.module != null) {
        this.module= {};
        console.log("清空之前的category:",this.category,"清空之前的categoryUniIds:",this.categoryUniIds);
        this.category=[];
        this.categoryUniIds=[];
        console.log("清空之后的category:",this.category,"清空之后的categoryUniIds:",this.categoryUniIds);
        this.module = this.$route.params.module;
        console.log("module根据uniId查询category:",SessionStorage.get("categoryChildrenDtoList"));
        this.module.categoryChildrenDtoList=SessionStorage.get("categoryChildrenDtoList") || {};
        for(let i=0;i<this.module.categoryChildrenDtoList.length;i++){
            this.category.push(this.module.categoryChildrenDtoList[0].categoryUniId);
        }
        console.log("push进入后的category:",this.category);
        this.category=this.category.join('');
        console.log("category数组转字符串:",this.category);
        if(this.category!=null && this.category.length>0){
            this.getCategory(this.category);
        }
        //this.category=JSON.stringify(this.category);
        //console.log("JSON转换后的category:",this.category);

        let optionModule = document.getElementById("optionModule");
        let submitBtn = document.getElementById("submitBtn");
        optionModule.innerHTML = '更新模块表';
        submitBtn.innerHTML = "立即更新";
    }
    //获取session中的moduleId
    let mainModule = SessionStorage.get("mainModule");
    console.log("session传入的mainModule:", mainModule);
    if (mainModule === null ) {
        this.module.parentId = 0;
    }else{
        this.module.parentId = 0;
    }
    //获取分类
    this.getCategorys();
    //1.初始化富文本
    $("#content").summernote({
        focus:true,
        height:300
    })
    //2.获取当前module的富文本内容
    $("#content").summernote('code',this.module.moduleContent);
},
…….
save(formName) {
    let _this = this;
    let responseMsg = '';
    console.log("新增模组:", this.module);
    //前端校验
    this.$refs[formName].validate((valid) => {
        if (valid) {
            //获取富文本内容,存入content
            let content=$("#content").summernote('code');
            console.log("富文本内容:",content);
            this.module.moduleContent=content;

            this.$axios.post(process.env.VUE_APP_SERVER + '/business/admin/module/saveMC', this.module)
                .then((response) => {
                    let resp = response.data;
                    responseMsg = response;
                    console.log("响应的正确信息:", responseMsg);
                    console.log("response.data:", resp);

                    if (resp.success) {
                        console.log("保存模块表成功:", resp.responseData);
                        this.$router.push("/business/module/set");
                        //引入全局变量toast提示
                        toast.success("保存成功", "bottom-end");
                    } else {
                        this.$notify({
                            title: '填写内容错误',
                            message: resp.responseMsg,
                            position: "top-right",
                            type: 'warning'
                        });
                    }
                })
        } else {
            console.log('error submit!!');
            this.$notify({
                title: '填写内容错误',
                message: '请按照提示内容填写正确信息',
                position: "top-right",
                type: 'warning'
            });
            return false;
        }
    });

},


4.页面小功能:admin页面时间更新


<div class="navTopItem">
    <li class="el-icon-paperclip"></li>
    <span class="loginInfo">欢迎 cevent 登录</span>
    <span class="currentTime">{{currentTimes}}</span>
</div>

……..

data() {
    return {
        message: '这里是登录页首页',
        activeIndex: '1',
        activeIndex2: '1',
        url: "/imgs/logo300-1.png",
        isCollapse: false,
        opensNav: [],
        activeValue: '',
        openedMenu: ["0", "1", "2", "3", "4"],
        currentTimes:'',
    }
},

……..

mounted() {
    let now='';
    let timeInterval=setInterval(()=>{
        now=Tool.dateFormat("yyyy-MM-dd hh:mm:ss");
        this.currentTimes=now;
    },1000);
  • tool工具类:日期格式化
//4.增加日期格式化方法
    dateFormat:function (format,date) {
        let result;
        if(!date){
            date=new Date();
        }
        const option={
            "y+":date.getFullYear().toString(),
            "M+":(date.getMonth()+1).toString(), //月份需要加1
            "d+":date.getDate().toString(), //day为一周的第几天,date为一个月的第几天
            "h+":date.getHours().toString(),
            "m+":date.getMinutes().toString(),
            "s+":date.getSeconds().toString()
        };
        for(let i in option){
            result=new RegExp("("+i+")").exec(format);
            if(result){
                format=format.replace(result[1],(result[1].length==1)?(option[i]):(option[i].padStart(result[1].length,"0")));
            }
        }
        return format;
    },

5.后端数据排序更新sortDto

public class SortDto {
    private String uniId;
    private int currentSort;
    private int newSort;

    public String getUniId() {
        return uniId;
    }

    public void setUniId(String uniId) {
        this.uniId = uniId;
    }

    public int getCurrentSort() {
        return currentSort;
    }

    public void setCurrentSort(int currentSort) {
        this.currentSort = currentSort;
    }

    public int getNewSort() {
        return newSort;
    }

    public void setNewSort(int newSort) {
        this.newSort = newSort;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("SortDto{");
        sb.append("uniId='").append(uniId).append('\'');
        sb.append(", currentSort=").append(currentSort);
        sb.append(", newSort=").append(newSort);
        sb.append('}');
        return sb.toString();
    }
}

6.service新增排序方法

//10.排序方法
@Transactional
public void sort(SortDto sortDto){
    //修改当前记录的排序值
    commonModuleMapper.updateSort(sortDto);
    //排序值变大,排序区间new-old值-1
    if(sortDto.getNewSort()>sortDto.getCurrentSort()){
        commonModuleMapper.moveSortForward(sortDto);
    }
    //排序值变小,排序区间值+1
    if(sortDto.getNewSort()<sortDto.getCurrentSort()){
        commonModuleMapper.moveSortBackward(sortDto);
    }
}

7.commonModuleMapper新增排序接口

//6.更新排序
int updateSort(SortDto sortDto);

//7.newSort>currentSort,new→current区间的排序-1,current=new,删除之前的current
int moveSortForward(SortDto sortDto);
//8.newSort<currentSort, new→current区间的排序+1,current=new,删除之前的current
int moveSortBackward(SortDto sortDto);

8.commonModuleMapper新增排序sql

<!--更新排序-->
<update id="updateSort" parameterType="cevent.source.cloudcenter.server.dto.SortDto">
    update cevent_module set `sort`=#{newSort} where uni_id=#{uniId}
</update>
<!--new>current,new→current区间排序各-1 ,new=current,删除之前的sort,<![CDATA[ ...避免符号报错 ]]>-->
<update id="moveSortForward" parameterType="cevent.source.cloudcenter.server.dto.SortDto">
    <![CDATA[
    update cevent_module set `sort`=(`sort`-1) where `sort`<=#{newSort} and `sort`>=#{currentSort}
    ]]>
</update>
<!--new<current,new→current区间排序各+1,new=current,删除之前的sort-->
<update id="moveSortBackward" parameterType="cevent.source.cloudcenter.server.dto.SortDto">
    <![CDATA[
    update cevent_module set `sort`=(`sort`+1) where `sort`>=#{newSort} and `sort`<=#{currentSort}
    ]]>
</update>

9.controller调用sort排序

//更新排序
@RequestMapping("/sort")
public ResponseDataDto sort(@RequestBody SortDto sortDto){
    LOG.info("传入的sortDto:{}",sortDto);
    ResponseDataDto responseData=new ResponseDataDto();
    moduleService.sort(sortDto);
    return responseData;
}


10.员工管理表生成

  • 建表sql
# 11.员工管理表
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee`(
	`uni_id` CHAR(8) NOT NULL DEFAULT '' COMMENT '唯一ID',
	`name` VARCHAR(50) NOT NULL COMMENT '姓名',
	`nick_name` VARCHAR(50) COMMENT '昵称',
	`login_name` VARCHAR(255) COMMENT '登录名',
	`password` VARCHAR(255) COMMENT '密码',
	`dep_id` CHAR(8) COMMENT '部门ID',
	`position` VARCHAR(50) COMMENT '职位',
	`icon` VARCHAR(255) COMMENT '头像',
	`motto` VARCHAR(255) COMMENT '座右铭',
	`intro` VARCHAR(1000) COMMENT '简介',
	`file_id` CHAR(8) COMMENT '关联文件ID',
	`create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(3) DEFAULT NULL COMMENT '修改时间',
	PRIMARY KEY (`uni_id`)
)ENGINE=INNODB DEFAULT charset=utf8mb4 COMMENT='员工管理表';
  • mybatis-generator自动生成



  • 更新module表,加入employee_id字段
## 增加employee_id关联
ALTER TABLE `cevent_module` ADD COLUMN (`employee_id` CHAR(8) COMMENT '员工|employee.id');

11.module页面加载员工信息



elementUI标签应用-Autocomplete自动匹配标签



addModule页面回显员工数据

mounted() {
    this.empList = SessionStorage.get(EMP_ALL);
    console.log(this.message);
    console.log("传入的params:", this.$route.params.module);
    if (this.$route.params.module != null) {
        this.module= {};
        console.log("清空之前的category:",this.category,"清空之前的categoryUniIds:",this.categoryUniIds);
        this.category=[];
        this.categoryUniIds=[];
        console.log("清空之后的category:",this.category,"清空之后的categoryUniIds:",this.categoryUniIds);
        this.module = this.$route.params.module;
        //更新员工姓名回显
        for (let i=0;i<this.empList.length;i++){
            if(this.empList[i].uniId===this.module.employeeId){
                this.emp=this.empList[i].name;
            }
        }
        console.log("module根据uniId查询category:",SessionStorage.get(MODULE_CATEGORY_CHILDREN));
        this.module.categoryChildrenDtoList=SessionStorage.get(MODULE_CATEGORY_CHILDREN) || {};
        for(let i=0;i<this.module.categoryChildrenDtoList.length;i++){
            this.category.push(this.module.categoryChildrenDtoList[0].categoryUniId);
        }
        console.log("push进入后的category:",this.category);
        this.category=this.category.join('');
        console.log("category数组转字符串:",this.category);
        if(this.category!=null && this.category.length>0){
            this.getCategory(this.category);
        }
        //this.category=JSON.stringify(this.category);
        //console.log("JSON转换后的category:",this.category);

        let optionModule = document.getElementById("optionModule");
        let submitBtn = document.getElementById("submitBtn");
        optionModule.innerHTML = '更新模块表';
        submitBtn.innerHTML = "立即更新";
    }


gitee提交,源码开放长期维护欢迎fork,关注,mark,点赞收藏转发

gitee地址:

https://gitee.com/cevent_OS/yameng-cevent-source-cloudcenter.git

相关推荐

悠悠万事,吃饭为大(悠悠万事吃饭为大,什么意思)

新媒体编辑:杜岷赵蕾初审:程秀娟审核:汤小俊审签:周星...

高铁扒门事件升级版!婚宴上‘冲喜’老人团:我们抢的是社会资源

凌晨两点改方案时,突然收到婚庆团队发来的视频——胶东某酒店宴会厅,三个穿大红棉袄的中年妇女跟敢死队似的往前冲,眼瞅着就要扑到新娘的高额钻石项链上。要不是门口小伙及时阻拦,这婚礼造型团队熬了三个月的方案...

微服务架构实战:商家管理后台与sso设计,SSO客户端设计

SSO客户端设计下面通过模块merchant-security对SSO客户端安全认证部分的实现进行封装,以便各个接入SSO的客户端应用进行引用。安全认证的项目管理配置SSO客户端安全认证的项目管理使...

还在为 Spring Boot 配置类加载机制困惑?一文为你彻底解惑

在当今微服务架构盛行、项目复杂度不断攀升的开发环境下,SpringBoot作为Java后端开发的主流框架,无疑是我们手中的得力武器。然而,当我们在享受其自动配置带来的便捷时,是否曾被配置类加载...

Seata源码—6.Seata AT模式的数据源代理二

大纲1.Seata的Resource资源接口源码2.Seata数据源连接池代理的实现源码3.Client向Server发起注册RM的源码4.Client向Server注册RM时的交互源码5.数据源连接...

30分钟了解K8S(30分钟了解微积分)

微服务演进方向o面向分布式设计(Distribution):容器、微服务、API驱动的开发;o面向配置设计(Configuration):一个镜像,多个环境配置;o面向韧性设计(Resista...

SpringBoot条件化配置(@Conditional)全面解析与实战指南

一、条件化配置基础概念1.1什么是条件化配置条件化配置是Spring框架提供的一种基于特定条件来决定是否注册Bean或加载配置的机制。在SpringBoot中,这一机制通过@Conditional...

一招解决所有依赖冲突(克服依赖)

背景介绍最近遇到了这样一个问题,我们有一个jar包common-tool,作为基础工具包,被各个项目在引用。突然某一天发现日志很多报错。一看是NoSuchMethodError,意思是Dis...

你读过Mybatis的源码?说说它用到了几种设计模式

学习设计模式时,很多人都有类似的困扰——明明概念背得滚瓜烂熟,一到写代码就完全想不起来怎么用。就像学了一堆游泳技巧,却从没下过水实践,很难真正掌握。其实理解一个知识点,就像看立体模型,单角度观察总...

golang对接阿里云私有Bucket上传图片、授权访问图片

1、为什么要设置私有bucket公共读写:互联网上任何用户都可以对该Bucket内的文件进行访问,并且向该Bucket写入数据。这有可能造成您数据的外泄以及费用激增,若被人恶意写入违法信息还可...

spring中的资源的加载(spring加载原理)

最近在网上看到有人问@ContextConfiguration("classpath:/bean.xml")中除了classpath这种还有其他的写法么,看他的意思是想从本地文件...

Android资源使用(android资源文件)

Android资源管理机制在Android的开发中,需要使用到各式各样的资源,这些资源往往是一些静态资源,比如位图,颜色,布局定义,用户界面使用到的字符串,动画等。这些资源统统放在项目的res/独立子...

如何深度理解mybatis?(如何深度理解康乐服务质量管理的5个维度)

深度自定义mybatis回顾mybatis的操作的核心步骤编写核心类SqlSessionFacotryBuild进行解析配置文件深度分析解析SqlSessionFacotryBuild干的核心工作编写...

@Autowired与@Resource原理知识点详解

springIOCAOP的不多做赘述了,说下IOC:SpringIOC解决的是对象管理和对象依赖的问题,IOC容器可以理解为一个对象工厂,我们都把该对象交给工厂,工厂管理这些对象的创建以及依赖关系...

java的redis连接工具篇(java redis client)

在Java里,有不少用于连接Redis的工具,下面为你介绍一些主流的工具及其特点:JedisJedis是Redis官方推荐的Java连接工具,它提供了全面的Redis命令支持,且...