Explorar o código

表单构建布局型组件新增按钮

RuoYi %!s(int64=5) %!d(string=hai) anos
pai
achega
c04ea0221a

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
ruoyi-ui/src/assets/icons/svg/button.svg


+ 15 - 0
ruoyi-ui/src/utils/generator/config.js

@@ -406,6 +406,21 @@ export const layoutComponents = [
406
     layoutTree: true,
406
     layoutTree: true,
407
     children: [],
407
     children: [],
408
     document: 'https://element.eleme.cn/#/zh-CN/component/layout'
408
     document: 'https://element.eleme.cn/#/zh-CN/component/layout'
409
+  },
410
+  {
411
+    layout: 'colFormItem',
412
+    label: '按钮',
413
+    changeTag: true,
414
+    labelWidth: null,
415
+    tag: 'el-button',
416
+    tagIcon: 'button',
417
+    span: 24,
418
+    default: '主要按钮',
419
+    type: 'primary',
420
+    icon: 'el-icon-search',
421
+    size: 'medium',
422
+    disabled: false,
423
+    document: 'https://element.eleme.cn/#/zh-CN/component/button'
409
   }
424
   }
410
 ]
425
 ]
411
 
426
 

+ 21 - 0
ruoyi-ui/src/utils/generator/html.js

@@ -107,6 +107,18 @@ const layouts = {
107
 }
107
 }
108
 
108
 
109
 const tags = {
109
 const tags = {
110
+  'el-button': el => {
111
+    const {
112
+      tag, disabled
113
+    } = attrBuilder(el)
114
+    const type = el.type ? `type="${el.type}"` : ''
115
+    const icon = el.icon ? `icon="${el.icon}"` : ''
116
+    const size = el.size ? `size="${el.size}"` : ''
117
+    let child = buildElButtonChild(el)
118
+
119
+    if (child) child = `\n${child}\n` // 换行
120
+    return `<${el.tag} ${type} ${icon} ${size} ${disabled}>${child}</${el.tag}>`
121
+  },
110
   'el-input': el => {
122
   'el-input': el => {
111
     const {
123
     const {
112
       disabled, vModel, clearable, placeholder, width
124
       disabled, vModel, clearable, placeholder, width
@@ -272,6 +284,15 @@ function attrBuilder(el) {
272
   }
284
   }
273
 }
285
 }
274
 
286
 
287
+// el-buttin 子级
288
+function buildElButtonChild(conf) {
289
+  const children = []
290
+  if (conf.default) {
291
+    children.push(conf.default)
292
+  }
293
+  return children.join('\n')
294
+}
295
+
275
 // el-input innerHTML
296
 // el-input innerHTML
276
 function buildElInputChild(conf) {
297
 function buildElInputChild(conf) {
277
   const children = []
298
   const children = []

+ 5 - 0
ruoyi-ui/src/utils/generator/render.js

@@ -26,6 +26,11 @@ function vModel(self, dataObject, defaultValue) {
26
 }
26
 }
27
 
27
 
28
 const componentChild = {
28
 const componentChild = {
29
+  'el-button': {
30
+    default(h, conf, key) {
31
+      return conf[key]
32
+    },
33
+  },
29
   'el-input': {
34
   'el-input': {
30
     prepend(h, conf, key) {
35
     prepend(h, conf, key) {
31
       return <template slot="prepend">{conf[key]}</template>
36
       return <template slot="prepend">{conf[key]}</template>