Mr_HJ / form-generator项目学习-增加自定义的超融组件(一)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

更多nbcio-boot功能请看演示系统

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://122.227.135.243:9888

尝试学习增加自己的一个超融组件,能支持数据库与字段,先把前端做好。

主要的流程如下:

1、utils\generator\config.js 中添加一个json

javascript 复制代码
// 超融组件配置
    __config__: {
      label: '超融文本',
      labelWidth: null,
      showLabel: true,
      changeTag: true,
      tag: 'sf-input',
      tagIcon: 'sfinput',
      defaultValue: undefined,
      required: false,
      tableName: "",
      layout: 'colFormItem',
      span: 24,
      document: 'https://element.eleme.cn/#/zh-CN/component/input',
      // 正则校验规则
      regList: []
    },
    // 组件的插槽属性
    __slot__: {
      prepend: '',
      append: ''
    },
    // 其余的为可直接写在组件标签上的属性
    placeholder: '请输入',
    style: {width: '100%'},
    clearable: true,
    'prefix-icon': '',
    'suffix-icon': '',
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false
  },

2、src\compontnes\目录下创建对应的组件

3、main.js中全局注册刚创建的组件

4、src\views\index\RightPanel.vue 中绑定第一步中json中添加的各个属性值

javascript 复制代码
<el-form-item
            v-if="activeData.__config__.tag==='sf-input'" label="数据库表">
            <el-select v-model="activeData.__config__.tableName" placeholder="请选择数据库表"
              v-hasPermi="['tool:gen:list']" @change="tableChange" filterable>
              <el-option v-for="item in tableList" :key="item.tableName" :value="item.tableName"
                :label="item.tableName?item.tableComment+'('+item.tableName+')':item.tableComment">
                <span >
                  {{ item.tableName?item.tableComment+'('+item.tableName+')':item.tableComment}}
                </span>
                <span>{{item.sub==false?'主表':'从表'}}</span>
              </el-option>
            </el-select>
          </el-form-item>
javascript 复制代码
<el-form-item v-if="activeData.__vModel__!==undefined && activeData.__config__.tableName"  label="字段名">
            <el-select v-model="activeData.__vModel__" placeholder="请选择字段" clearable
              filterable @change="fieldChange">

              <el-option-group label="">
                <el-option v-for="item in columnList" :key="item.columnId"
                  :value="item.columnName"
                  :label="item.columnName?item.columnComment+'('+item.columnName+')':item.javaType">
                </el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
javascript 复制代码
tableChange(table) {
      console.log("tableChange table",table)
      this.activeData.__config__.tableName = table
      const tableName = table
      this.getColumnList(tableName);
    },
    getColumnList(tableName) {
      if (tableName) {
        this.loading = true;
        getGenColumn(tableName).then(response => {
          this.columnList = response.rows;
          //this.total = response.total;
          this.loading = false;
        });
      }
    },

效果图如下:

相关推荐
荔枝吖5 分钟前
html2canvas+pdfjs 打印html
前端·javascript·html
文心快码BaiduComate11 分钟前
全运会,用文心快码做个微信小程序帮我找「观赛搭子」
前端·人工智能·微信小程序
合作小小程序员小小店11 分钟前
web网页开发,在线%档案管理%系统,基于Idea,html,css,jQuery,java,ssh,mysql。
java·前端·mysql·jdk·html·ssh·intellij-idea
合作小小程序员小小店16 分钟前
web网页开发,在线%物流配送管理%系统,基于Idea,html,css,jQuery,java,ssh,mysql。
java·前端·css·数据库·jdk·html·intellij-idea
三门26 分钟前
web接入扣子私有化智能体
前端
林小帅27 分钟前
AI “自动驾驶” 的使用分享
前端
起名时在学Aiifox35 分钟前
深入解析 Electron 打包中的 EPERM: operation not permitted 错误
前端·javascript·electron
游戏开发爱好者835 分钟前
Fiddler抓包工具完整教程 HTTPHTTPS抓包、代理配置与API调试实战技巧(开发者进阶指南)
前端·测试工具·ios·小程序·fiddler·uni-app·webview
华仔啊1 小时前
20个CSS实用技巧,10分钟从小白变大神!
前端·css
起名时在学Aiifox1 小时前
Vue3 + Element Plus 表格排序实战:基于状态字段的智能排序方案
前端·javascript·vue.js·element plus