• jeecgboot 可编辑表格弹窗富文本框


            最近使用jeecgboot框架的JEditableTable做一个数据维护,有一个需求是用户要录入SQL语句,帮他顺序执行SQL,由于SQL又臭又长,小小的input框没办法显示全,导致每次需要在txt里编辑好了再贴进去,修改也是一样。

           如图,只能显示几个字,多了就看不到了。

            于是乎,测试的胖子提出需求,需要点击弹出一个框,完全显示编辑内容。

            实现步骤:

    1. 给可编辑表格特定类型的框添加事件监听,不能影响可编辑表格现有的功能
    2. 做一个模态框组件,用于显示和编辑
    3. 完善父页面和模态框组件之间的数据通信

            直接上代码:

    源码里没有点击事件,需要自己加

     源码里增加一个处理函数,用于父子组件传值

     父组件中的column,增加使能点击事件的属性

     父组件监听子组件的事件

     

    父组件处理子组件传过来的数据

    最后再新建一个弹窗页面即可

    这里使用了compute,用于防止子组件直接修改父组件的值

    1. <script>
    2. import store from '@/store'
    3. import { mapGetters } from 'vuex'
    4. import { getAction, postAction, getFileAccessHttpUrl } from '@/api/manage'
    5. import moment from 'moment'
    6. export default {
    7. name: 'FckEditerDialog',
    8. components: {},
    9. props: {
    10. paramData: {
    11. type: String,
    12. default: ''
    13. },
    14. },
    15. computed: {
    16. paramCopy: {
    17. get() {
    18. return this.paramData
    19. },
    20. set(val) {
    21. this.$emit('saveContentInfo', val)
    22. }
    23. }
    24. },
    25. data () {
    26. return {
    27. title:'编辑器',
    28. width:896,
    29. visible: false,
    30. disableSubmit: false,
    31. usercode: '',
    32. userId: '',
    33. execProcess: '',
    34. }
    35. },
    36. created() {
    37. this.userId = this.userInfo().id;
    38. },
    39. mounted() {
    40. },
    41. destroyed: function () {
    42. },
    43. methods: {
    44. ...mapGetters(['nickname', 'avatar', 'userInfo']),
    45. add () {
    46. this.execProcess = '';
    47. this.visible=true
    48. },
    49. edit (record) {
    50. this.visible=true
    51. },
    52. close () {
    53. this.$emit('close');
    54. this.visible = false;
    55. },
    56. handleOk () {
    57. this.$emit('close');
    58. this.visible = false;
    59. // let data = this.paramData
    60. // this.$emit('saveContentInfo', data);
    61. // this.paramData = '';
    62. },
    63. submitCallback(){
    64. this.$emit('ok');
    65. this.visible = false;
    66. },
    67. handleCancel () {
    68. this.close()
    69. this.visible = false;
    70. },
    71. }
    72. }
    73. script>

     效果图:

     

    全屏效果

     

    这样保存后会有很多HTML后台处理的时候需要去除,附上工具类:

     

    1. public class FckEditorUtil {
    2. public static Pattern p = Pattern.compile("\\s*|\t|\r|\n|");
    3. /**
    4. * 去掉字符串中的 \t \r \n
    5. *

    6. * param str
    7. *
    8. * @return
    9. * @author Rex
    10. */
    11. public static String replaceBlank(String str) {
    12. String dest = "";
    13. if (str != null) {
    14. Matcher m = p.matcher(str);
    15. dest = m.replaceAll("");
    16. }
    17. return dest;
    18. }
    19. /**
    20. * 删除Html标签
    21. *

    22. * param inputString
    23. *
    24. * @return
    25. * @author Rex
    26. */
    27. public static String removeHtmlTag(String inputString) {
    28. if (inputString == null) {
    29. return null;
    30. }
    31. String htmlStr = inputString; // 含html标签的字符串
    32. String textStr = "";
    33. try {
    34. //定义script的正则表达式{或]*?>[\\s\\S]*?<\\/script>
    35. String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>";
    36. //定义style的正则表达式{或]*?>[\\s\\S]*?<\\/style>
    37. String regEx_style = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>";
    38. // 定义HTML标签的正则表达式
    39. String regEx_html = "<[^>]+>";
    40. // 定义一些特殊字符的正则表达式 如:     
    41. String regEx_special = "\\&[a-zA-Z]{1,10};";
    42. textStr = getString(htmlStr, regEx_script, regEx_style, regEx_html, regEx_special);
    43. } catch (Exception e) {
    44. e.printStackTrace();
    45. }
    46. return textStr;// 返回文本字符串
    47. }
    48. private static String getString(String htmlStr, String... args) {
    49. Pattern p_script;
    50. Matcher m_script;
    51. for (String regEx: args) {
    52. p_script = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
    53. m_script = p_script.matcher(htmlStr);
    54. htmlStr = m_script.replaceAll(" "); // 过滤
    55. }
    56. return htmlStr;
    57. }
    58. }

  • 相关阅读:
    (数据结构)数制转换——将一个十进制整数转换成一个非十进制数
    EXPLAIN命令使用及功能介绍
    wordpress遇到的问题
    PCB走线规则
    python爬虫入门到精通路线
    你知道SPI的原理以及实现?
    手把手写深度学习(15):在Hugging Face上构建自己的语料库
    开源不到 48 小时获 35k star 的推荐算法「GitHub 热点速览」
    DOM&BOM
    面试算法常考题之-------逆波兰式合集
  • 原文地址:https://blog.csdn.net/nickDaDa/article/details/133551781